补题: 1001. Add More Zero 1011KazaQ's Socks
来源:互联网 发布:微信朋友圈数据采集 编辑:程序博客网 时间:2024/06/03 02:56
先补比较简单的1001 和1011,最后再来看1002
1001
Add More Zero
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others)
Total Submission(s): 2245 Accepted Submission(s): 1053
Nowadays, he is preparing a thought-provoking problem on a specific type of supercomputer which has ability to support calculations of integers between
As a young man born with ten fingers, he loves the powers of
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
164
Case #1: 0Case #2: 19
答案就是:⌊log10(2m−1),注意到不存在10k=2m10^k = 2^m ,所以⌊log10(2m−1)⌋=⌊log102m⌋=⌊mlog102⌋
AC代码
#include<iostream>#include<cstdio>using namespace std;int main(){ double a=0.301029995663; int m; int l=0; while(scanf("%d",&m)!=EOF) { l++; cout<<"Case #"<<l<<": "<<(int)(m*a)<<endl; } return 0;}
KazaQ's Socks
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others)Total Submission(s): 2375 Accepted Submission(s): 1074
At the beginning, he has
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
KazaQ would like to know which pair of socks he should wear on the
For each case, there is a line contains two numbers
3 73 64 9
Case #1: 3Case #2: 1Case #3: 2
题意:KazaQ 有n双袜子,按1到n编号放在柜子里,他早上选一双穿,号码小的优先,晚上把穿的袜子放篮子里,当篮子里的袜子达到n-1双时,他会洗袜子,第二天晚上会把洗过的袜子放到柜子里,问第k天他穿的是哪双袜子?
题目分析:
n=3时
n k ans
3 1 1
3 2 2
3 3 3
3 4 1
3 5 2
3 6 1
3 7 3
3 8 1
3 9 2
3 10 1
3 11 3
。。。。。。
n=4时
n k ans
4 1 1
4 2 2
4 3 3
3 4 4
4 5 1
4 6 2
4 7 3
4 8 1
4 9 2
4 10 4
4 11 1
4 12 2
4 13 3
4 14 1
4 15 2
4 16 4
观察规律:前n天,第i天袜子是i,之后,天数-n,即i-n, n-1为周期,第i天, (i-n)%(n-1) 不为0, 袜子为(i-n)%(n-1),否则 (i-n)/(n-1)为奇数 袜子n-1 ;
(i-n)/(n-1)为偶数,袜子为n。
AC代码
#include<cstdio>#include<iostream>using namespace std;int main(){ long long n,k; int t=0; while(scanf("%lld%lld",&n,&k)!=EOF) { t++; cout<<"Case #"<<t<<": "; if(k<=n) { cout<<k<<endl; continue; } else { long long m=(k-n)%(n-1); if(m==0) m=n; long long rare=(k-n)/(n-1); if(m<n-1) { cout<<m<<endl; } else { if(rare%2) cout<<n-1<<endl; else cout<<n<<endl; } } } return 0;}
\left \lfloor \log_{10}(2^m - 1) \right \rfloor = \left \lfloor \log_{10}{2^m} \right \rfloor = \left \lfloor m \log_{10}{2} \right \rfloor
- 补题: 1001. Add More Zero 1011KazaQ's Socks
- KazaQ's Socks
- KazaQ's Socks
- KazaQ's Socks
- 1011.KazaQ's Socks
- hdu6043--KazaQ's Socks
- HDU6043-KazaQ's Socks
- KazaQ's Socks
- HDU-KazaQ's Socks
- KazaQ's Socks
- KazaQ's Socks
- KazaQ's Socks
- hdu6043 KazaQ's Socks
- KazaQ's Socks
- KazaQ's Socks
- KazaQ's Socks HDU
- 1001.Add More Zero
- 杭电 KazaQ's Socks
- python实现SMTP客户端
- 嫌Word转换太麻烦!那是你没选对转换工具
- [RK3288][Android6.0] WiFi之网络时间定期同步更新
- xml与map之间互转(java)
- [转]详解C指针
- 补题: 1001. Add More Zero 1011KazaQ's Socks
- python多线程学习总结
- yii2 composer安装 高级应用
- 关于easyUI
- ssh整合(1)
- HomeAssistant--Sonoff接入BH1750FVI光线感应器
- luhn计算最后一位校验位(ICCID,银行卡号)
- CSU-ACM2017暑假集训2-二分搜索 C
- 3d转换(立方体旋转效果)