Time Limit: 2000/1000 MS (Java/Others)
Memory Limit: 131072/131072 K (Java/Others)
Nowadays, he is preparing a thought-provoking problem on a specific type of supercomputer which has ability to support calculations of integers between 0 and (2m−1) (inclusive).
As a young man born with ten fingers, he loves the powers of 10 so much, which results in his eccentricity that he always ranges integers he would like to use from 1 to 10k (inclusive).
For the sake of processing, all integers he would use possibly in this interesting problem ought to be as computable as this supercomputer could.
Given the positive integer m , your task is to determine maximum possible integer k that is suitable for the specific supercomputer.
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <set>
#include <map>
#include <list>
#include <deque>
#include <queue>
#include <stack>
#include <string>
#include <vector>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>
using namespace std;
typedef long long ll;
#pragma comment(linker, "/STACK:102400000,102400000")
#define Abs(x) ((x^(x >> 31))-(x>>31))
#define Swap(a,b) (a^=b,b^=a,a^=b)
#define PI acos(-1.0)
#define INF 0x3f3f3f3f
#define EPS 1e-8
#define MOD 1000000007
#define max_ 105
#define maxn 200002
//////////////////////////////////////////
int main()
{
int m,cas=1;
while(cin>>m)
{
int ans = log10(2) * m;
printf("Case #%d: %d\n",cas++,ans);
}
return 0;
}
Total Submission(s): 2668 Accepted Submission(s): 1137
The path between each two different nodes is unique, of which we define the value as the number of different colors appearing in it.
Calculate the sum of values of all paths on the tree that has n(n−1)2 paths in total.
For each test case, the first line contains one positive integers n , indicating the number of node. (2≤n≤200000)
Next line contains n integers where the i -th integer represents ci , the color of node i . (1≤ci≤n)
Each of the next n−1 lines contains two positive integers x,y (1≤x,y≤n,x≠y) , meaning an edge between node x and node y .
It is guaranteed that these edges form a tree.
Division Game Time Limit: 10000/5000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others)
Total Submission(s): 220 Accepted Submission(s): 97
The operation of the i -th round is to modify the pile of stones numbered (i−1)modk . In each round, you should remove from this pile some stones (at least one stone), satisfying that the number of stones in this pile before this operation is a multiple of the number of stones in this pile after operation, which means that you ought to remain at least one stone in this pile.
The game is ended if there exists at least one pile containing only one stone. Given two positive integers n and k , your task is to calculate for each pile the number of the possible operation plans that it is the last operated pile before the game is ended.
The integer n may be very large, so the prime-factor decomposition of n will be given, in other words, if n=∏mi=1peii , then the integers m and (pi,ei) (1≤i≤m) will be given, but the integer n will not.
The answer may be very large, so you only need to give the value of the answer modulo 985661441 .
For each test case:
The first line contains two positive integers m and k , satisfying that 1≤m,k≤10 .
In next m lines, the i -th line contains two positive integers pi and ei , satisfying that 2≤pi≤109, ei≥1, ∑mi=1ei≤105 .
It is guaranteed that p1,p2,⋯,pm are distinct.
About 200 test cases in total, where no more than 5 cases satisfy ∑mi=1ei≥104 .