A 首先发现对于2操作,每种素因子可以单独考虑,然后取出步数最多的计入答案,然后分别加上对每种素因子的1操作; 第二步我犯了个错误,以为最优方案是把素因子指数按二进制操作,在1的位置执行1操作,0的位置执行2操作倍增; 然后发现是错的,执行一次1操作后,之后的2操作可以完全代替1操作,这样可以节省对其他素因子的1操作... int getbit(int x) { ,res=; while (cur<x) cur+=cur,res++; return res; } int BigFatIntege…
Problem Statement You are a genealogist specializing in family trees of vampires. Vampire family trees differ from human family trees. In particular, vampires are "born" in a different way. The only way to create a new vampire is that an ex…
A 裸最短路. class TravelOnMars { public: int minTimes(vector <int>, int, int); }; vector<int> e[maxn]; int n; int dist(int a,int b) { if (a>b) swap(a,b); int res = min( b-a , a+n-b); return res; } int d[maxn],inq[maxn]; queue<int> q; int…
Problem Statement Cat Noku has just finished writing his first computer program. Noku's computer has m memory cells. The cells have addresses 0 through m-1. Noku's program consists of n instructions. The instructions have mutually independent ef…
Problem Statement Wolf Sothe and Cat Snuke are playing a card game. The game is played with exactly 100 cards. The cards are numbered from 1 to 100. The game is played as follows: First, Cat Snuke chooses the goal: an integer N between 1 and 100…