Блог пользователя parina

Автор parina, 16 лет назад, По-английски
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]
  • Проголосовать: нравится
  • -2
  • Проголосовать: не нравится

16 лет назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится
I suppose the mistake is here:
  printf(" %d",j/10);
Why 10? (Besides, this space can be unnecessary)
16 лет назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится
test 10 10 100
16 лет назад, скрыть # |
 
Проголосовать: нравится +3 Проголосовать: не нравится
Test from Aleksey (he forgot to change the language): 10 10 100
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