ZR#997

ZR#997

解法:

找找规律就出来了,全场最简单的一道题。

CODE:

#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>

using namespace std;

#define LL long long
#define N 100010

LL n,m,T,ans;
 
int main() {
    scanf("%lld",&T);
    while(T--) {
        scanf("%lld%lld",&n,&m);
        LL s = 0;
        for(int i = 1 ; i <= 10 ; i++) 
            s += m * i % 10;
        ans = s * (n / m / 10);
        for(int i = 1 ; i <= (n / m) % 10 ; i++) 
            ans += m * i % 10;
        printf("%lld \n",ans);
    }
    //system("pause");
    return 0;
}

猜你喜欢

转载自www.cnblogs.com/Repulser/p/11488151.html