zoukankan      html  css  js  c++  java
  • Codeforces 204A

    我也搞不懂为什么我每次做这种明明很简单清晰的题目总是会想出那么操蛋的办法,诶。贴个正常的:

     1 #include <cstdio>
     2 typedef long long LL;
     3 LL a[20];
     4 LL count(LL num){
     5     int bit[20],cnt = 0;
     6     LL tmp = num;
     7     while(tmp > 0){
     8         bit[cnt++] = tmp % 10;
     9         tmp /= 10;
    10     }
    11     if(cnt == 1)    return num - 1;
    12     LL ans = 9;
    13     for(int i = 1;i < cnt - 1;i++){
    14         ans += 9 * a[i-1];
    15     }
    16     ans += (bit[cnt-1] - 1) * a[cnt-2];
    17     for(int i = cnt-2;i >= 1;i--){
    18         ans += bit[i] * a[i-1];
    19     }
    20     if(bit[cnt-1] < bit[0]) ans++;
    21     return ans;
    22 }
    23 int main(){
    24     a[0] = 1;
    25     for(int i = 1;i <= 18;i++)  a[i] = a[i-1] * 10;
    26     LL L,R;
    27     while(scanf("%I64d%I64d",&L,&R) != EOF){
    28         printf("%I64d
    ",count(R+1)-count(L));
    29     }
    30     return 0;
    31 }
    View Code
  • 相关阅读:
    君の名は~ 观后感
    dp1,明天补题解
    【bzoj1222】[HNOI2001]产品加工
    Daily~Miracles
    luogu 1273有线电视网
    luogu 1373
    codeforces 721C
    codeforces 706E
    The~Best~Chanteur~宇多田ヒカル
    codeforces706D
  • 原文地址:https://www.cnblogs.com/zhexipinnong/p/3238236.html
Copyright © 2011-2022 走看看