「CF477A」Dreamoon and Sums
题解
求 ∑ x (div ( x , b) / mod ( x , b ) = k && 1<=k<=a)
设 m = mod ( x , b ) 则 x = m * k * b + m
1 <= m <= b – 1
则 ∑ x = ( k * b + 1 ) * b * ( b – 1 ) / 2 ,k可以直接枚举。。。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
#include<iostream> #include<cstdio> #include<cstdlib> #include<algorithm> #include<cmath> #include<cstring> #define inf 1000000000 #define ll long long #define mod 1000000007 using namespace std; int read() { int 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*10+ch-'0';ch=getchar();} return x*f; } ll a,b,ans; int main() { a=read();b=read(); for(ll i=1;i<=a;i++) ans=(ans+(i*b+1)%mod*(b*(b-1)/2%mod))%mod; printf("%I64d",ans); return 0; } |
Subscribe