• ZROI#997


    ZROI#997
    这是某场(CF(Div.3))(C)题.我当时是选择了现场码.
    因为那场(CF)我没打.这个题我当时第一眼就觉得有循环节.
    于是就直接考虑循环节,发现它是对的.于是就只需要处理一下细节就好.
    (Code:)

    #include <algorithm>
    #include <iostream>
    #include <cstdlib>
    #include <cstring>
    #include <cstdio>
    #include <string>
    #include <vector>
    #include <queue>
    #include <cmath>
    #include <ctime>
    #include <map>
    #include <set>
    #define MEM(x,y) memset ( x , y , sizeof ( x ) )
    #define rep(i,a,b) for (int i = a ; i <= b ; ++ i)
    #define per(i,a,b) for (int i = a ; i >= b ; -- i)
    #define pii pair < int , int >
    #define X first
    #define Y second
    #define rint read<int>
    #define int long long
    #define pb push_back
    
    using std::set ;
    using std::pair ;
    using std::max ;
    using std::min ;
    using std::priority_queue ;
    using std::vector ;
    using std::swap ;
    using std::sort ;
    using std::unique ;
    using std::greater ;
    
    template < class T >
        inline T read () {
            T x = 0 , f = 1 ; char ch = getchar () ;
            while ( ch < '0' || ch > '9' ) {
                if ( ch == '-' ) f = - 1 ;
                ch = getchar () ;
            }
           while ( ch >= '0' && ch <= '9' ) {
                x = ( x << 3 ) + ( x << 1 ) + ( ch - 48 ) ;
                ch = getchar () ;
           }
       return f * x ;
    }
    
    const int N = 100 ; bool mk[15] ;
    int n , m , T , tot ;
    vector < int > tmp ;
    
    signed main (int argc , char * argv[]) {
        T = rint () ;
        while ( T -- ) {
            n = rint () ; m = rint () ; tot = 0 ; int sum = 0 ;
            if ( m > n ) { puts ("0") ; continue ; }
            if ( n == m ) { printf ("%lld
    " , m % 10 ) ; continue ; }
            rep ( i , 0 , 10 ) mk[i] = false ; tmp.clear () ;
            while ( true ) {
                ++ tot ; int t = m * tot % 10 ; if ( mk[t] ) break ;
                tmp.pb ( t ) ; sum += t ; mk[t] = true ;
            }
            int rpt = ( n / m ) / (int)tmp.size () ; int ans = sum * rpt ;
            rep ( i , 0 , n / m % (int)tmp.size () - 1 ) ans += tmp[i] ;
            printf ("%lld
    " , ans ) ;
        }
        return 0 ;
    }
    
    May you return with a young heart after years of fighting.
  • 相关阅读:
    python 生成器和推导式
    python 函数名 ,闭包 ,迭代器
    python 函数
    python BMI指数
    python 实现购物车的优化
    python 文件操作
    python set集合 深浅拷贝(难点)
    css中的float和position
    css一些简单的例子
    SQL测试题
  • 原文地址:https://www.cnblogs.com/Equinox-Flower/p/11486593.html
Copyright © 2020-2023  润新知