I am WA in this problem [http://www.codeforces.com/problemset/problem/71/B]
I don't know why.Please give me some sample input-output Or have a look on my code.
[code]
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<string.h>
#include<iostream>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cstring>
#include<algorithm>
using namespace std;
#define diff(x,y) x>y ? (x-y):(y-x)
#define i64d unsigned long long
int main(){
int n,i,k,t,l,c;
int j;
scanf("%d %d %d",&n,&k,&t);
l=((t*n)/100);
j=(t*n)%100;
for(i=l-1;i>=0;i--){
if(i==l-1)
;
else
printf(" ");
printf("%d",k);
}
printf(" %d",j/10);
for(i=l+1;i<n;i++)
printf(" 0");
printf("\n");
return 0;
}
[/code]
I don't know why.Please give me some sample input-output Or have a look on my code.
[code]
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<string.h>
#include<iostream>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cstring>
#include<algorithm>
using namespace std;
#define diff(x,y) x>y ? (x-y):(y-x)
#define i64d unsigned long long
int main(){
int n,i,k,t,l,c;
int j;
scanf("%d %d %d",&n,&k,&t);
l=((t*n)/100);
j=(t*n)%100;
for(i=l-1;i>=0;i--){
if(i==l-1)
;
else
printf(" ");
printf("%d",k);
}
printf(" %d",j/10);
for(i=l+1;i<n;i++)
printf(" 0");
printf("\n");
return 0;
}
[/code]
And question from naagi:
printf(" %d",j/10);
Why 10? (Besides, this space can be unnecessary)
I think you'd better use printf("%2d", j); instead - it automatically adds necessary spaces (or if you need zeros - just change format to %02d
(But as I understand "%2d" is useless here, we just need spaces between numbers)
One more test for the topic starter:
1 100 99
Is the answer is 9?
The progress bar consists of 1 element, there are 100 possible colors, you should show 99th.
The answer is "99".
(This test shows the mistake I mentioned.)
My code gives correct answer on your mentioned testcases.
Here is the newly modified code.
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<string.h>
#include<iostream>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cstring>
#include<algorithm>
using namespace std;
#define diff(x,y) x>y ? (x-y):(y-x)
#define i64d unsigned long long
int main(){
int n,i,k,t,l,c,s;
int j;
scanf("%d %d %d",&n,&k,&t);
l=((t*n)/100);
j=(t*n)%100;
s=k/n;
c=0;
for(i=0;i<l;i++){
if(i!=0)
printf(" ");
printf("%d",k);
c++;
}
if(c!=n){
if(c!=0)
printf(" ");
printf("%d",j/n);
}
for(i=0;i<n-(l+1);i++)
printf(" 0");
printf("\n");
return 0;
}
2 98 54
3 98 68
3 3 3
Here you can take any submission on your language and get the answers for your tests.
3rd test is:
Input
j=(t*n)%100;
...
printf("%d",j/n);
You output ((t * n) % 100)/n. Why? I have no idea.
Let's read the statement...
The degree of the process's completion is measured in percents. Let the process be t% completed. Then the following inequation is fulfilled:
In our case, t = 50, nk = 9 * 25 = 225.
?
really fool I am.