标签:nbsp scan namespace targe def its while lld for
枚举余数
#include<bits/stdc++.h> using namespace std; typedef long long ll; int main() { int T; scanf("%d",&T); while(T--){ ll n,m,p; scanf("%lld%lld%lld",&n,&m,&p); ll t=n/p; ll ans=0; for(ll r=0;r<=p-1;r++){ if(r==0){ ans+=t*m; }else if(r<=n%p){ ans+=(t+1)*(m/(p/__gcd(r,p))); } else ans+=t*(m/(p/__gcd(r,p))); } cout<<ans<<‘\n‘; } }
标签:nbsp scan namespace targe def its while lld for
原文地址:https://www.cnblogs.com/liulex/p/11333372.html