Educational Codeforces Round 7

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Educational Codeforces Round 7相关的知识,希望对你有一定的参考价值。

A - Infinite Sequence

题意:有一种这样的无限序列数 1,1,2,1,2,3.....   (如果最大数n,那么就有从1到n的所有1到n的数);

思路:题意只给了1秒、直接模拟肯定超时,我用的是二分找下界

 

 1 #include<iostream>
 2 using namespace std;
 3 long long f(long long x)
 4 {
 5     return (1+x)*x/2;
 6 }
 7 long long search(long long x)
 8 {
 9     int l,r,m;
10     l=0;r=1e8;
11     while(l<=r){
12         m=(l+r)/2;
13         if(f(m)>=x)    r=m-1;
14         else        l=m+1; 
15     }
16     return l;
17 }
18 int main()
19 {
20     long long n;
21     while(cin >> n){
22         long long ans;
23         ans=search(n);
24         ans=n-f(ans-1);
25         cout << ans << endl;
26     }
27 }

 

 1 #include<stdio.h>
 2 int main()
 3 {
 4     long long int n,i,k;
 5     scanf("%lld",&n);
 6     i=1;
 7     k=n;
 8     while(k>i)
 9     {
10         k-=i;
11         i++;
12     }
13     printf("%lld",k);
14     return 0;
15 }

 

 

B - The Time   

题意:给一个时间给你,然后给你个分钟时间给你,让你相加

思路:直接模拟算

 

 1 #include<iostream>
 2 #include<cstdio>
 3 using namespace std;
 4 int main()
 5 {
 6     int a,b;
 7     while(~scanf("%d%*c%d%*c",&a,&b)){
 8         int c;scanf("%d",&c);
 9         int ans=c/60;
10         int cns=c%60;
11         ans+=(cns+b)/60;
12         ans+=a;
13         cns=(cns+b)%60;
14         ans=ans%24;
15         printf("%02d:%02d\n",ans,cns);
16     }
17 }

 

以上是关于Educational Codeforces Round 7的主要内容,如果未能解决你的问题,请参考以下文章

Educational Codeforces Round 7 A

Educational Codeforces Round 7

Educational Codeforces Round 90

Educational Codeforces Round 33

Codeforces Educational Codeforces Round 54 题解

Educational Codeforces Round 27