parina's blog

By parina, 13 years ago, In English
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]
  • Vote: I like it
  • -2
  • Vote: I do not like it

| Write comment?
13 years ago, # |
  Vote: I like it +3 Vote: I do not like it
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
  • 13 years ago, # ^ |
    Rev. 2   Vote: I like it 0 Vote: I do not like it
    Thanks, I always forget to look at language buttons :/

    (But as I understand "%2d" is useless here, we just need spaces between numbers)

    One more test for the topic starter:
    1 100 99
    • 13 years ago, # ^ |
        Vote: I like it 0 Vote: I do not like it
      naagi,
      Is the answer is 9? 
      • 13 years ago, # ^ |
          Vote: I like it 0 Vote: I do not like it
        No.
        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.)
    • 13 years ago, # ^ |
        Vote: I like it 0 Vote: I do not like it
      I was working on wrong method.Changed now. Still WA on testcase 3.Please help me.
      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;
      }


      • 13 years ago, # ^ |
          Vote: I like it 0 Vote: I do not like it
        PLease tell me what will be the answer for these testcases?

        2 98 54
        3 98 68
        3 3 3
      • 13 years ago, # ^ |
          Vote: I like it 0 Vote: I do not like it
        You can see all tests if you click on any correct submit.
        3rd test is:

        Input
        9 25 50
        Output
        25 25 25 25 12 0 0 0 0

        The problem is still in "j"
        j=(t*n)%100;
        ...
        printf("%d",j/n);

        You output ((t * n) % 100)/n. Why? I have no idea.
        • 13 years ago, # ^ |
            Vote: I like it 0 Vote: I do not like it
          Now,I am sure that my algo for finding J is wrong.Will you please explain for me that how is that 12 for testcase 9 25 50?
          • 13 years ago, # ^ |
              Vote: I like it 0 Vote: I do not like it

            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.

            ?

          • 13 years ago, # ^ |
              Vote: I like it 0 Vote: I do not like it
            okay..got it..thnx for your co-operation.



            really fool I am.