您的位置:首页 > 其它

Codeforces Round #358 (Div. 2) A. Alyona and Numbers

2016-06-22 11:24 549 查看

Codeforces Round #358 (Div. 2) A. Alyona and Numbers

题意:找在x属于[1,n]、y属于[1,m]找出(x+y)%5==0的个数,n和m范围都是10^6,只能一重循环,不然TLE,结果cnt一定是longlong不然爆掉的;考虑两种情况,5的倍数和非5的倍数,只有非5的倍数要考虑最后一种情况。

#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdio>
#include <ctime>
#include <set>
#include <map>
#include <cmath>
using namespace std;
typedef long long LL;
int main(){
int n,m,j;
while(~scanf("%d %d",&n,&m)){
LL cnt = 0;
for(int i=1;i<=n;i++){
if(i%5==0) { //5的倍数
cnt+= m/5;
continue;
}
cnt += (m/5); //非5的倍数
for(int j=m%5;j>=1;j--){ //最后一位
if((i+j)%5==0){
cnt++;
}
}
//cout<<i<<" "<<cnt<<endl;
}
printf("%lld\n",cnt);
}
return 0;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  codeforces 水题