fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. int main()
  4. {
  5. long long t;
  6. cin>>t;
  7. while(t--)
  8. {
  9. long long k,d=0;
  10. cin>>k;
  11. long long a[10000] ;
  12. for ( int i=0 ; i < k ; i++ )
  13. {
  14. a[i] = i+1;
  15. }
  16. long long slow = 0 ;
  17. for ( long long fast=1; fast<k-1;fast++)
  18. {
  19.  
  20. if ( a[slow] < a[fast] )
  21. {
  22. if ( (a[slow] + a[fast]) == k )
  23. {
  24. slow++;
  25. fast=0;
  26. d++;
  27. }
  28. if ( ( a[slow] + a[fast] ) < k )
  29. {
  30. d++;
  31. }
  32. }
  33.  
  34. }
  35. d=d-slow;
  36. cout<<d<<endl;
  37. }
  38. return 0;
  39. }
Success #stdin #stdout 1.63s 5280KB
stdin
96
6721
1341
2296
9445
8517
7601
9961
7729
4101
4551
1377
2001
3719
9145
3831
7126
2845
1969
8369
4241
6283
4017
9876
6609
5025
7537
2171
6433
5907
6481
301
5061
3153
3105
3137
6103
7305
6461
6673
4597
6726
1
2115
3201
6385
8705
1569
9793
6710
3469
2477
7377
4393
2713
4365
5959
7126
7959
9609
3137
4949
8373
2876
9877
2700
3581
8626
4701
7243
1876
9601
7789
2621
9817
2689
7081
4857
3911
3901
5313
2369
4963
7553
7041
2313
8401
2113
55
2769
571
4513
5183
5073
6275
5001
485
stdout
11289600
448900
1316756
22297284
18130564
14440000
24800400
14930496
4202500
5175625
473344
1000000
3455881
20903184
3667225
12691406
2022084
968256
17505856
4494400
9865881
4032064
24378906
10916416
6310144
14197824
1177225
10342656
8720209
10497600
22500
6400900
2483776
2408704
2458624
9308601
13337104
10432900
11128896
5280804
11306406
0
1117249
2560000
10188864
18939904
614656
23970816
11252670
3006756
1532644
13601344
4822416
1838736
4761124
8874441
12691406
15832441
23078416
2458624
6120676
17522596
2066406
24383844
1821150
3204100
18597656
5522500
13111641
878906
23040000
15163236
1716100
24088464
1806336
12531600
5895184
3822025
3802500
7054336
1401856
6155361
14258176
12390400
1336336
17640000
1115136
729
1915456
81225
5089536
6713281
6431296
9840769
6250000
58564