太菜了,一个题目
#include <bits/stdc++.h>
using namespace std;
int main()
{
int s,v1,v2,t1,t2;
while(cin>>s>>v1>>v2>>t1>>t2){
int res1=2*t1+s*v1;
int res2=2*t2+s*v2;
if(res1<res2)
cout<<"First"<<endl;
else
if(res1>res2)
cout<<"Second"<<endl;
else
cout<<"Friendship"<<endl;
}
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.
3 11
1
3 99
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.
#include <bits\stdc++.h>
using namespace std;
const int maxn=100005;
int main()
{
int k;
char s[maxn];
while(cin>>k){
cin>>s;
int a[15]={0};
int sum=k,ans=0;
for(int i=0;i<strlen(s);i++){
a[s[i]-'0']++;
sum-=s[i]-'0';
}
for(int i=0;i<=9;i++){
for(int j=1;j<=a[i];j++){
if(sum>0)
sum-=9-i,ans++;
else
break;
}
if(sum<=0)
break;
}
cout<<ans<<endl;
}
return 0;
}
这次主要不是题目有多难,而是自己英语太差,题意理解错了,一直错