Codeforces Round #427 (Div. 2) A B C D
来源:互联网 发布:美容院连锁软件 编辑:程序博客网 时间:2024/06/06 02:15
Two boys decided to compete in text typing on the site "Key races". During the competition, they have to type a text consisting of s characters. The first participant types one character in v1 milliseconds and has ping t1 milliseconds. The second participant types one character in v2 milliseconds and has ping t2milliseconds.
If connection ping (delay) is t milliseconds, the competition passes for a participant as follows:
- Exactly after t milliseconds after the start of the competition the participant receives the text to be entered.
- Right after that he starts to type it.
- Exactly t milliseconds after he ends typing all the text, the site receives information about it.
The winner is the participant whose information on the success comes earlier. If the information comes from both participants at the same time, it is considered that there is a draw.
Given the length of the text and the information about participants, determine the result of the game.
The first line contains five integers s, v1, v2, t1, t2 (1 ≤ s, v1, v2, t1, t2 ≤ 1000) — the number of characters in the text, the time of typing one character for the first participant, the time of typing one character for the the second participant, the ping of the first participant and the ping of the second participant.
If the first participant wins, print "First". If the second participant wins, print "Second". In case of a draw print "Friendship".
5 1 2 1 2
First
3 3 1 1 1
Second
4 5 3 1 5
Friendship
In the first example, information on the success of the first participant comes in 7 milliseconds, of the second participant — in 14 milliseconds. So, the first wins.
In the second example, information on the success of the first participant comes in 11 milliseconds, of the second participant — in 5 milliseconds. So, the second wins.
In the third example, information on the success of the first participant comes in 22 milliseconds, of the second participant — in 22 milliseconds. So, it is be a draw.
水题
#include <cstdio>#include <iostream>#include <string.h>#include <string> #include <map>#include <queue>#include <vector>#include <set>#include <algorithm>#include <math.h>#include <cmath>#include <bitset>#define mem0(a) memset(a,0,sizeof(a))#define meminf(a) memset(a,0x3f,sizeof(a))using namespace std;typedef long long ll;typedef long double ld;const int maxn=100005,inf=0x3f3f3f3f;const ll llinf=0x3f3f3f3f3f3f3f3f; const ld pi=acos(-1.0L);int main() {//freopen("input.txt","r",stdin);//freopen("output.txt","w",stdout);int s,v1,v2,t1,t2;cin >> s >> v1 >> v2 >> t1 >> t2;if (v1*s+2*t1<v2*s+2*t2) printf("First"); else if (v1*s+2*t1>v2*s+2*t2) printf("Second"); else printf("Friendship");return 0;}
Some natural number was written on the board. Its sum of digits was not less than k. But you were distracted a bit, and someone changed this number to n, replacing some digits with others. It's known that the length of the number didn't change.
You have to find the minimum number of digits in which these two numbers can differ.
The first line contains integer k (1 ≤ k ≤ 109).
The second line contains integer n (1 ≤ n < 10100000).
There are no leading zeros in n. It's guaranteed that this situation is possible.
Print the minimum number of digits in which the initial number and n can differ.
311
1
399
0
In the first example, the initial number could be 12.
In the second example the sum of the digits of n is not less than k. The initial number could be equal to n.
一个数,让你修改最少位数使数位和至少为k。
尽量把小的改成9就可以了。
#include <cstdio>#include <iostream>#include <string.h>#include <string> #include <map>#include <queue>#include <vector>#include <set>#include <algorithm>#include <math.h>#include <cmath>#include <bitset>#define mem0(a) memset(a,0,sizeof(a))#define meminf(a) memset(a,0x3f,sizeof(a))using namespace std;typedef long long ll;typedef long double ld;const int maxn=100005,inf=0x3f3f3f3f;const ll llinf=0x3f3f3f3f3f3f3f3f; const ld pi=acos(-1.0L);char s[maxn];int a[105];int main() {int n,k,len,i,j,ans=0,sum;scanf("%d",&k);scanf("%s",s);len=strlen(s);sum=k;mem0(a);for (i=0;i<len;i++) {a[s[i]-'0']++;sum-=s[i]-'0';}for (i=0;i<=9;i++) {for (j=1;j<=a[i];j++) {if (sum>0) sum-=9-i,ans++; else break;}if (sum<=0) break;}cout << ans;return 0;}
- Codeforces Round #427 (Div. 2) A B C D
- Codeforces Round #179 (Div. 2)A、B、C、D
- Codeforces Round #186 (Div. 2)A、B、C、D、E
- Codeforces Round #202 (Div. 2) (A、B、C、D)
- Codeforces Round #211 (Div. 2)(A,B,C,D)
- Codeforces Round #220 (Div. 2)(A,B,C,D)
- Codeforces Round #231 (Div. 2)A, B, C, D
- Codeforces Round #258 (Div. 2)-(A,B,C,D,E)
- Codeforces Round #246 (Div. 2) A,B,C,D
- Codeforces Round #261 (Div. 2) A,B,C,D,E
- Codeforces Round #259 (Div. 2) A/B/C/D
- Codeforces Round #257 (Div. 2) A/B/C/D
- Codeforces Round #256 (Div. 2) A/B/C/D
- Codeforces Round #262 (Div. 2)-A,B,C,D
- Codeforces Round #263 (Div. 2) A,B,C,D,E
- Codeforces Round #264 (Div. 2) A,B,C,D,E
- Codeforces Round #276 (Div. 2) A B C D
- Codeforces Round #277 (Div. 2) A,B,C,D,E
- WebGL之旅(十七) 带纹理的立方体
- Codeforces 834D The Bakery 线段树优化DP
- UnknownHostException的处理
- Linux:Unable to locate package
- ubuntu下postgreSQL安装配置
- Codeforces Round #427 (Div. 2) A B C D
- PostgreSQL入门
- AngularJS 的 Promise
- Spring DATA JPA 中findAll 进行OrderBy
- C语言之最好理解的通过函数指针作为参数实现回调函数
- ionic自动刷新
- 正则化方法:L1和L2 regularization、数据集扩增、dropout
- docker中使用redis
- Codeforces Round #427 (Div. 2) C. Star sky 二维前缀和