2017 多校系列 1

来源:互联网 发布:淘宝店铺绑定 编辑:程序博客网 时间:2024/05/24 01:47

Add More Zero

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others)
Total Submission(s): 303    Accepted Submission(s): 224


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 (2m1)(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.
 

Input
The input contains multiple test cases. Each test case in one line contains only one positive integer m, satisfying 1m105.
 

Output
For each test case, output "Case #xy" in one line (without quotes), where x indicates the case number starting from 1 and y denotes the answer of corresponding case.
 

Sample Input
164
 

Sample Output
Case #1: 0Case #2: 19
 

Source
2017 Multi-University Training Contest - Team 1
 

Recommend
liuyiding   |   We have carefully selected several similar problems for you:  6044 6043 6042 6041 6040 

题意:给你一个m,然后问你2的m次方减一是10的几次方,求k
题解:两边取对数,然后近似求解就好了,水题一枚。



ac code:
#include <iostream>#include <cstdio>#include <cstring>#include <string>#include <cstdlib>#include <cmath>#include <vector>#include <list>#include <deque>#include <queue>#include <iterator>#include <stack>#include <map>#include <set>#include <algorithm>#include <cctype>using namespace std;#define si1(a) scanf("%d",&a)#define si2(a,b) scanf("%d%d",&a,&b)#define sd1(a) scanf("%lf",&a)#define sd2(a,b) scanf("%lf%lf",&a,&b)#define ss1(s)  scanf("%s",s)#define pi1(a)    printf("%d\n",a)#define pi2(a,b)  printf("%d %d\n",a,b)#define mset(a,b)   memset(a,b,sizeof(a))#define forb(i,a,b)   for(int i=a;i<b;i++)#define ford(i,a,b)   for(int i=a;i<=b;i++)typedef long long LL;const int N=1100001;const int M=6666666;const int INF=0x3f3f3f3f;const double PI=acos(-1.0);const double eps=1e-7;int m;int main(){    int cas=0;    while(~si1(m))    {        int k=(int)m*(log10(2));//减一可以近似约掉,毕竟m越大,感觉不怎么影响        printf("Case #%d: %d\n",++cas,k);    }    return 0;}



KazaQ's Socks

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others)
Total Submission(s): 248    Accepted Submission(s): 165


Problem Description
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 n1 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.
 

Input
The input consists of multiple test cases. (about 2000)

For each case, there is a line contains two numbers n,k (2n109,1k1018).
 

Output
For each test case, output "Case #xy" 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 73 64 9
 

Sample Output
Case #1: 3Case #2: 1Case #3: 2
 

Source
2017 Multi-University Training Contest - Team 1
 

Recommend
liuyiding   |   We have carefully selected several similar problems for you:  6044 6043 6042 6041 6040 


题意:有n双袜子,每天从篮子里拿出号码最小的一双来穿(号码从1到n),当已经穿了n-1双时就要开始洗袜子,到第二天晚上才能放回篮子里。问你第k天穿几号袜子。
题解:找规律,列一下n=3,n=4,n=5看一下就知道了(基本列到9天差不多规律就有了)


ac code:
#include <iostream>#include <cstdio>#include <cstring>#include <string>#include <cstdlib>#include <cmath>#include <vector>#include <list>#include <deque>#include <queue>#include <iterator>#include <stack>#include <map>#include <set>#include <algorithm>#include <cctype>using namespace std;#define si1(a) scanf("%d",&a)#define si2(a,b) scanf("%d%d",&a,&b)#define sd1(a) scanf("%lf",&a)#define sd2(a,b) scanf("%lf%lf",&a,&b)#define ss1(s)  scanf("%s",s)#define pi1(a)    printf("%d\n",a)#define pi2(a,b)  printf("%d %d\n",a,b)#define mset(a,b)   memset(a,b,sizeof(a))#define forb(i,a,b)   for(int i=a;i<b;i++)#define ford(i,a,b)   for(int i=a;i<=b;i++)typedef long long LL;const int N=1100001;const int M=6666666;const int INF=0x3f3f3f3f;const double PI=acos(-1.0);const double eps=1e-7;LL n;LL k;int main(){    int cas=0;    while(~scanf("%lld%lld",&n,&k))    {        if(k<=n)        {            printf("Case #%d: %d\n",++cas,k);            continue;        }        k=(k-n)%(2*(n-1));        if(k==0)            printf("Case #%d: %d\n",++cas,n);        else if(k<=n-1)            printf("Case #%d: %d\n",++cas,k);        else        {            k=k%(n-1);            printf("Case #%d: %d\n",++cas,k);        }    }    return 0;}


原创粉丝点击