1. Find all factors of C-R
2. Output those factors which are > R
Got WAs during the contest.

Many people solved this one in the contest. Is there anything I missed? Just hope it's not a hidden bug from the re-used code.
Moderator: Board moderators
In the case R == C, the answer should be "0".
+1Krzysztof Duleba wrote:Huh? That's perfectly right. This is what that page is for.abishek wrote:its not right to expect ppl to refresh the clarifications page.
Code: Select all
Case #1: 1 2 4 5 10 20 25 50 100
Code: Select all
15
2000000000 40
10000000 0
909090 909090
0 0
100 0
84946644 544
146 4
4843 45
818481 215
7181994 51851
61 7
441 0
441 10
99999999 3333
818181 16
Code: Select all
Case #1: 46 56 70 92 115 140 161 184 230 280 322 460 644 805 920 1288 1610 3220 6440 310559 621118 1242236 1552795 2173913 2484472 3105590 4347826 6211180 7142857 8695652 10869565 12422360 14285714 17391304 21739130 28571428 35714285 43478260 49999999 57142856 71428570 86956520 99999998 142857140 199999996 249999995 285714280 399999992 499999990 999999980 1999999960
Case #2: 1 2 4 5 8 10 16 20 25 32 40 50 64 80 100 125 128 160 200 250 320 400 500 625 640 800 1000 1250 1600 2000 2500 3125 3200 4000 5000 6250 8000 10000 12500 15625 16000 20000 25000 31250 40000 50000 62500 78125 80000 100000 125000 156250 200000 250000 312500 400000 500000 625000 1000000 1250000 2000000 2500000 5000000 10000000
Case #3: 0
Case #4: 0
Case #5: 1 2 4 5 10 20 25 50 100
Case #6: 849461 1698922 3397844 4247305 8494610 16989220 21236525 42473050 84946100
Case #7: 71 142
Case #8: 2399 4798
Case #9: 4597 9194 409133 818266
Case #10: 134531 245867 7130143
Case #11: 9 18 27 54
Case #12: 1 3 7 9 21 49 63 147 441
Case #13: 431
Case #14: 4242 4286 6429 6666 7777 12858 15001 15554 23331 23573 30002 45003 46662 47146 70719 90006 141438 165011 216443 330022 432886 495033 649329 990066 1298658 1515101 2380873 3030202 4545303 4761746 7142619 9090606 14285238 16666111 33332222 49998333 99996666
Case #15: 163633 818165
Code: Select all
deleted after accepted...
Code: Select all
#include <stdio.h>
#include <math.h>
#include <algorithm>
using namespace std;
#define max_f 2000000
int fac[max_f+1],k;
void factor(int n){
int i,sr;
k=0;
sr=sqrt(n);
for(i=1;i<=sr;i++){
if(n%i==0){
fac[k++]=i;
if(i!=sr)
fac[k++]=n/i;
}
}
}
int main(){
int n,T,cas=1,i,r;
//freopen("in.txt","r",stdin);
scanf("%d",&T);
while(T--){
scanf("%d %d",&n,&r);
printf("Case #%d:",cas++);
if(n==r){printf(" 0\n");continue;}
n-=r;
factor(n);
sort(fac,fac+k);
for(i=0;i<k;i++)
if(fac[i]>r){
printf(" %d",fac[i]);
}
printf("\n");
}
return 0;
}