HDU 多校联合 6033 6043
2017-07-26 09:34
141 查看
http://acm.hdu.edu.cn/showproblem.php?pid=6033
Add More Zero
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others)Total Submission(s): 449 Accepted Submission(s): 319
[align=left]Problem Description[/align]
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 (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.
[align=left]Input[/align]
The input contains multiple test cases. Each test case in one line contains only one positive integer m, satisfying 1≤m≤105.
[align=left]Output[/align]
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.
[align=left]Sample Input[/align]
1
64
[align=left]Sample Output[/align]
Case #1: 0 Case #2: 19
10^k>=2^m-1;k=m*(log2/log10) 向下取整
#include <iostream> #include <algorithm> #include <cstring> #include <cstdio> #include <vector> #include <cstdlib> #include <iomanip> #include <cmath> #include <ctime> #include <map> #include <set> using namespace std; #define lowbit(x) (x&(-x)) #define max(x,y) (x>y?x:y) #define min(x,y) (x<y?x:y) #define MAX 100000000000000000 #define MOD 1000000007 #define pi acos(-1.0) #define ei exp(1) #define PI 3.141592653589793238462 #define INF 0x3f3f3f3f3f #define mem(a) (memset(a,0,sizeof(a))) typedef long long ll; int main() { int m; int cast=0; while(scanf("%d",&m)!=EOF) { printf("Case #%d: %0.f\n",++cast,floor(m*1.0*log(2.0)/log(10.0)));//floor 向下取整 } return 0; }
KazaQ's Socks
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others)Total Submission(s): 389 Accepted Submission(s): 246
[align=left]Problem Description[/align]
KazaQ wears socks everyday.
At the beginning, he has n pairs of socks numbered from 1 to n in his closets.
Every morning, he puts on a pair of socks which has the smallest number in the closets.
Every evening, he puts this pair of socks in the basket. If there are n−1 pairs of socks in the basket now, lazy KazaQ has to wash them. These socks will be put in the closets again in tomorrow evening.
KazaQ would like to know which pair of socks he should wear on the k-th day.
[align=left]Input[/align]
The input consists of multiple test cases. (about 2000)
For each case, there is a line contains two numbers n,k (2≤n≤109,1≤k≤1018).
[align=left]Output[/align]
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.
[align=left]Sample Input[/align]
3 7
3 6
4 9
[align=left]Sample Output[/align]
Case #1: 3
Case #2: 1
Case #3: 2
#include <iostream> #include <algorithm> #include <cstring> #include <cstdio> #include <vector> #include <cstdlib> #include <iomanip> #include <cmath> #include <ctime> #include <map> #include <set> using namespace std; #define lowbit(x) (x&(-x)) #define max(x,y) (x>y?x:y) #define min(x,y) (x<y?x:y) #define MAX 100000000000000000 #define MOD 1000000007 #define pi acos(-1.0) #define ei exp(1) #define PI 3.141592653589793238462 #define INF 0x3f3f3f3f3f #define mem(a) (memset(a,0,sizeof(a))) typedef long long ll; //前n天顺序出现,后来前n-2天顺序出现,n-1,n交替出现 //1.2.3.4.1.2.3.1.2.4.1.2.3.1.2.4........ int main() { ll n,m,cast=0,ans; while(scanf("%lld%lld",&n,&m)!=EOF) { printf("Case #%lld: ",++cast); if(m<=n) printf("%lld\n",m); else { ans=(m-n)/(n-1)%2; if((m-n)%(n-1)==0) printf("%lld\n",ans==1?n-1:n); else printf("%lld\n",(m-n)%(n-1)); } } return 0; }
相关文章推荐
- HDU 多校联合第七场
- 多校联合训练10&&HDU 5861 Road
- hdu 4865 Peter's Hobby(2014 多校联合第一场 E)
- hdu 4649 Professor Tian 多校联合训练的题
- HDU 4868 Information Extraction(2014 多校联合第一场 H)
- hdu 4865 Peter's Hobby(2014 多校联合第一场 E)
- HDU 4869 Turn the pokers (2014 多校联合第一场 I)
- HDU 4655 2013多校联合赛第6场 Cut Pieces
- 【HDU 4905 多校联合】The Little Devil II【DP+四边形不等式优化】
- 2015多校联合训练赛 hdu 5305 Friends 2015 Multi-University Training Contest 2 枚举+剪枝
- hdu 4308 Saving Princess claire_ 广搜 多校联合赛第七题
- HDU 5734 Acperience(数学推导【多校联合】)
- 2013多校联合3 1010 No Pain No Game(hdu 4630)
- hdu 4320 Arcane Numbers 1 多校联合赛(三)第一题
- HDU 多校联合第三场
- hdu 4361 2013多校联合训练第3场最后一题
- hdu 5324 Boring Class 2015多校联合训练赛3 分治,最长不降子序列,最小字典序
- hdu多校联合Peter's Hobby
- hdu 5319(多校联合赛)
- 17 多校 - 1 - 1011 - KazaQ's Socks (HDU 6043)