2017多校训练1
Source
Add More Zero【数学/思维】
Time Limit: 2000/1000 MS (Java/Others)
Memory Limit: 131072/131072 K (Java/Others)
Problem Description
There is a youngster known for amateur propositions concerning several mathematical hard problems.
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 (2
m
−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 10
k![]()
(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.
Nowadays, he is preparing a thought-provoking problem on a specific type of supercomputer which has ability to support calculations of integers between 0
As a young man born with ten fingers, he loves the powers of 10
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
Input
The input contains multiple test cases. Each test case in one line contains only one positive integer m
, satisfying 1≤m≤10
5![]()
.
Output
For each test case, output "Case #x
: y
" in one line (without quotes), where x
indicates the case number starting from 1
and y
denotes the answer of corresponding case.
Sample Input
1
64
Sample Output
Case #1: 0
Case #2: 19
【题意】:求比2^m - 1小的10^k的最大的K值。
【分析】:因为2^m的尾数最小都是2,所以2^m-1不会改变它的位数。两边直接取对数,ln(10^k) = ln(2^m) -> k = ln(2)*m
【代码】:
数学推理/逻辑思维
Total Submission(s): 2668 Accepted Submission(s): 1137
Time Limit: 10000/5000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others)
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
#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;
}
Colorful Tree
Time Limit: 6000/3000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others)Total Submission(s): 2668 Accepted Submission(s): 1137
Problem Description
There is a tree with n
nodes, each of which has a type of color represented by an integer, where the color of node i
is c
i![]()
.
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.
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)
Input
The input contains multiple test cases.
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 c
i![]()
, the color of node i
. (1≤c
i
≤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.
For each test case, the first line contains one positive integers n
Next line contains n
Each of the next n−1
It is guaranteed that these edges form a tree.
Output
For each test case, output "Case #x
: y
" in one line (without quotes), where x
indicates the case number starting from 1
and y
denotes the answer of corresponding case.
Sample Input
3
1 2 1
1 2
2 3
6
1 2 1 3 2 1
1 2
1 3
2 4
2 5
3 6
Sample Output
Case #1: 6
Case #2: 29
【题意】:
【分析】:
【代码】:
Division Game
Time Limit: 10000/5000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others)
Total Submission(s): 220 Accepted Submission(s): 97
Problem Description
There are k
piles of stones in a circle, numbered from 0
to k−1
, where the number of the stones in each pile is n
initially. You can do some round operations, where the initial round is numbered as the 1
-st round.
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=∏
m
i=1
p
e
i![]()
i![]()
, then the integers m
and (p
i
,e
i
)
(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
.
The operation of the i
The game is ended if there exists at least one pile containing only one stone. Given two positive integers n
The integer n
The answer may be very large, so you only need to give the value of the answer modulo 985661441
Input
The input contains multiple test cases.
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 p
i![]()
and e
i![]()
, satisfying that 2≤p
i
≤10
9
,
e
i
≥1,
∑
m
i=1
e
i
≤10
5![]()
.
It is guaranteed that p
1
,p
2
,⋯,p
m![]()
are distinct.
About 200
test cases in total, where no more than 5
cases satisfy ∑
m
i=1
e
i
≥10
4![]()
.
For each test case:
The first line contains two positive integers m
In next m
It is guaranteed that p
About 200
Output
For each test case, output "Case #x
: y
0![]()
y
1![]()
⋯
y
k−1![]()
" in one line (without quotes), where x
indicates the case number starting from 1
and y
i![]()
(0≤i<k)
denotes the number of the possible operation plans modulo 985661441
for the pile numbered i
of corresponding case.
Sample Input
1 1
2 2
2 1
3 1
5 1
1 2
2 3
2 2
2 4
5 4
Sample Output
Case #1: 2
Case #2: 3
Case #3: 6 4
Case #4: 1499980 1281085
【题意】:
【分析】:
【代码】: