fork(1) download
  1. /*--.--.--.--.--.--.--.--.--.--.--.--.--*
  2.  * By-Rohit Singh *
  3.  * CS , MNNIT Allahabad *
  4.  * rohitmnnit1459@gmail.com *
  5.  *--.--.--.--.--.--.--.--.--.--.--.--.--*/
  6.  
  7. #include <iostream>
  8. #include <cstdio>
  9. #include <vector>
  10. #include <map>
  11. #include <queue>
  12. #include <stack>
  13. #include <cstring>
  14. #include <algorithm>
  15. #include <cstdlib>
  16. #include <cmath>
  17. #include <set>
  18. #include <limits.h>
  19. #include <assert.h>
  20. //#include <unordered_map>
  21. using namespace std;
  22.  
  23. #define mp make_pair
  24. #define pb push_back
  25. #define X first
  26. #define Y second
  27. #define null NULL
  28. #define ll long long
  29. #define llu unsigned long long
  30. #define MAX 200005
  31. #define mod 1000000007
  32. #define inf 1e16
  33. #define pp pair <int, int>
  34.  
  35. typedef double db;
  36. typedef long double ldb;
  37. typedef pair <int, int> pii;
  38. typedef pair <ll, ll> pll;
  39. typedef pair <ll, int> pli;
  40. typedef pair <ldb, ldb> pdd;
  41.  
  42. const db PI = 3.141592653589793238;
  43. #define abs(x) ((x)>0?(x):-(x))
  44. //#define pop pop_back()
  45. #define scan(x) scanf("%d",&x)
  46. #define print(x) printf("%d\n",x)
  47. #define scanll(x) scanf("%lld",&x)
  48. #define scanllu(x) scanf("%llu",&x)
  49. #define printll(x) printf("%lld\n",x)
  50.  
  51. #define rep(i,n) for(int i=0;i<n;i++)
  52. #define REP(i,a,b) for(int i=a;i<=b;i++)
  53. #define PER(i,a,b) for(int i=b;i>=a;i--)
  54. ll powmod(ll a,ll b) {ll res=1;a%=mod;for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
  55. //**********************************************HAPPY CODDING*****************************************************//
  56. int ind;
  57. llu arr[100], n, ans, ex, gc, num;
  58.  
  59. void compute(llu n) {
  60. int i, j;
  61. ind = arr[0] = 0;
  62. while (n) {
  63. arr[++ind] = n%10;
  64. n /= 10;
  65. }
  66. for (i = 1,j = ind ; i <= j ; i++,j--) {
  67. swap(arr[i], arr[j]);
  68. }
  69. REP(i,1,ind) {
  70. arr[i] ^= arr[i-1];
  71. }
  72. }
  73. llu gcd(llu a, llu b) {
  74. return (!a ? b : gcd(b%a, a));
  75. }
  76. int main() {
  77.  
  78. int t, rem;
  79. scan(t);
  80. while (t--) {
  81. scanllu(n);
  82. compute(n);
  83. ans = 0;
  84. num = n;
  85. while (n) {
  86. ind--;
  87. ans += (llu)(n/10)*(llu)45;
  88. rem = n%10;
  89. ex = 0;
  90. while (rem) {
  91. ex += (arr[ind]^rem);
  92. rem--;
  93. }
  94. ans += ex;
  95. n /= 10;
  96. }
  97. gc = gcd(ans, num);
  98. ans /= gc;
  99. num /= gc;
  100. printf("%llu/%llu\n", ans, num);
  101. }
  102. return 0;
  103. }
Runtime error #stdin #stdout 0s 3468KB
stdin
Standard input is empty
stdout
Standard output is empty