Niloy007

B. Grandfather Dovlet’s calculator

Jul 8th, 2020
80
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <bits/stdc++.h>
  2. #define MAX 100005
  3. #define MOD 1e9
  4. #define pb push_back
  5. #define pairs pair<int, int>
  6. #define vi vector<int>
  7. #define vb vector<bool>
  8. #define vii vector<pairs>
  9. #define lb lower_bound
  10. #define ub upper_bound
  11. #define ll long long
  12. #define endl '\n'
  13. using namespace std;
  14. /* ----------------------------------------------------------------------------------- */
  15.  
  16. #define fastInput ios_base::sync_with_stdio(false), cin.tie(NULL);
  17. #define all(x) x.begin(), x.end()
  18. #define scan(a) scanf("%d", &a)
  19. #define scanll(a) scanf("%lld", &a)
  20. #define scanD(a) scanf("%lf", &a)
  21. #define print(a) printf("%d\n", a)
  22. #define printll(a) printf("%lld\n", a)
  23. #define printD(a) printf("%lf\n", a)
  24. #define printTwo(a) printf("%.2lf\n", a);
  25. #define read(x) freopen(x, "r", stdin)
  26. #define write(x) freopen(x, "w", stdout)
  27. #define rep(i, a, n) for (int i = a; i < n; i++)
  28. #define REP(i, a, n) for (int i = a; i <= n; i++)
  29. #define inputArray(a,n) rep(i, 0, n) cin >> a[i];
  30. #define copyArray(a,temp,n) rep(i, 0, n) temp[i]=a[i];
  31. #define printArray(a,n) rep(i, 0, n) cout << a[i] << " "; cout << endl;
  32.  
  33. /* ----------------------------------------------------------------------------------- */
  34.  
  35. #define Cases  cout << "Case " << ++Case << ": ";
  36. #define __test int tt; int Case=0; cin >> tt; while(tt--)
  37. #define showTime cerr << "time = " << (clock() / CLOCKS_PER_SEC) << " sec" << '\n';
  38.  
  39. #define dbgA2(A, n, m) {cout<<"--> "<<#A<<" = \n";rep(i, 0, n){rep(j, 0, n){cout<<A[i][j]<<" ";}cout<<"\n";}cout<<"\n";}
  40. #define dbgA(A, n) {cout<<" --> "<<#A<<" = (";rep(i, 0, n)cout<<A[i]<<" ";cout<<")\n";}
  41. #define dbg(args...) {string sss(#args);sss+=',';cout<<" --> ";debugger::call(all(sss), args);cout<<"\n";}
  42.  
  43. /* ----------------------------------------------------------------------------------- */
  44.  
  45. ll gcd(ll n, ll m) { return m ? gcd(m, n % m) : n; }
  46. ll lcm(ll n, ll m) { return n / gcd(n, m) * m; }
  47.  
  48. struct debugger {
  49.     typedef string::iterator si;
  50.     static void call(si it, si ed) {}
  51.     template<typename T, typename ... aT>
  52.     static void call(si it, si ed, T a, aT... rest) {
  53.         string b;
  54.         for(; *it!=','; ++it)
  55.             if(*it!=' ')
  56.                 b+=*it;
  57.         cout << b << "=" << a << " ";
  58.         call(++it, ed, rest...);
  59.     }
  60. };
  61.  
  62. /* ----------------------------------------------------------------------------------- */
  63.  
  64. int arr[10] = {6, 2, 5, 5, 4, 5, 6, 3, 7, 6};
  65.  
  66.  
  67. void solve() {
  68.     int n, k;
  69.     scan(n);
  70.     scan(k);
  71.     int sum = 0;
  72.     REP(i, n, k) {
  73.         int a = i;
  74.         while(a > 0) {
  75.             int temp = a % 10;
  76.             sum += arr[temp];
  77.             a /= 10;
  78.         }
  79.     }
  80.     cout << sum << endl;
  81. }
  82.  
  83. int main() {
  84. #ifdef Niloy
  85.     read("input.txt");
  86.     write("output.txt");
  87. #endif
  88.  
  89.     solve();
  90.  
  91.     // __test {
  92.     //     solve();
  93.     // }
  94.  
  95.     showTime;
  96.     return 0;
  97. }
RAW Paste Data