fork download
  1. #include <bits/stdc++.h>
  2. #define FOR(i,a,b) for(long long i=a;i<=b;i++)
  3. #define st first
  4. #define nd second
  5. #define checkbit(i,x) (((x)>>(i))&1)
  6. #define ALL(a) (a).begin(), (a).end()
  7. using namespace std;
  8. const long long MOD = 1e9 + 7;
  9. const int maxn = 1e3 + 5;
  10. const long long INF = 1e18;
  11. int n, m, q;
  12. bool check ( int x ) {
  13. long long s = 0;
  14. int cnt_c = 0;
  15. int cnt_l = 0;
  16. for ( int i = 1; i <= x; i++ ) {
  17. if ( x % i == 0 ) {
  18. s += i;
  19. if ( i % 2 != 0 ) cnt_l++;
  20. else cnt_c++;
  21. }
  22. }
  23. if ( s % 2 != 0 && cnt_c == cnt_l ) return true;
  24. else return false;
  25. }
  26. namespace sub12 {
  27. void solve ( long long x ) {
  28. long long cnt = 0;
  29. for ( int i = 1; i <= x; i++ ) {
  30. if ( x % i == 0 && check ( i ) ){
  31. ++cnt;
  32. }
  33. }
  34. cout << cnt << "\n";
  35. }
  36. }
  37. namespace sub3 {
  38. void solve ( long long x ) {
  39. if ( x % 2 != 0 ) {
  40. cout << 0 << "\n";
  41. return;
  42. }
  43. long long cnt = 0;
  44. for ( long long i = 1; i * i <= x; i++ ) {
  45. if ( x % ( 2 * i * i ) == 0 && ( i * i ) % 2 != 0 ){
  46. ++cnt;
  47. }
  48. }
  49. cout << cnt << "\n";
  50. }
  51. }
  52. void solve() {
  53. cin >> q;
  54. while ( q-- ) {
  55. long long x;
  56. cin >> x;
  57. if ( x <= 1e6 ) sub12::solve ( x );
  58. else if ( x > 1e6 && x <= 1e12 ) sub3::solve ( x );
  59. else if ( x > 1e12 && x <= 1e18 ) {
  60. long long k2 = 0;
  61. while ( x % 2 == 0 ) {
  62. k2++;
  63. x /= 2;
  64. }
  65. if ( k2 == 0 ) {
  66. cout << 0 << "\n";
  67. continue;
  68. }
  69. long long ans = 1;
  70. for ( long long i = 3; i * i <= x; i += 2 ) {
  71. if ( x % i == 0 ) {
  72. long long ki = 0;
  73. while ( x % i == 0 ) {
  74. ki++;
  75. x /= i;
  76. }
  77. ans *= ( ki / 2 + 1 );
  78. }
  79. }
  80. cout << ans << "\n";
  81. }
  82. }
  83. }
  84. int main() {
  85. freopen ( "test.inp", "r", stdin );
  86. freopen ( "test.out", "w", stdout );
  87. ios_base::sync_with_stdio ( false );
  88. cin.tie ( NULL );
  89. solve();
  90. return 0;
  91. }
  92.  
Success #stdin #stdout 0s 5316KB
stdin
Standard input is empty
stdout
Standard output is empty