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; }
相关文章推荐
- 【HDU 5366】The mook jong 详解
- Codeforces Round #197 (Div. 2)
- Codeforces Round #198 (Div. 1)
- Codeforces 405E Codeforces Round #238 (Div. 2)E
- Codeforces 407C Codeforces Round #239 (Div. 1)C
- HDU 5240 Exam (好水的题)
- CodeForces 449A - Jzzhu and Chocolate
- CodeForces 449 B. Jzzhu and Cities
- codeforces 618C. Constellation
- 北大—1006——Biorhythms
- Codeforces Round #349 (Div. 2) - C
- Codeforces Round #265 (Div. 2)
- Codeforces #310 div2 C. Case of Matryoshkas
- 时间计算(heaven.pas/cpp)
- 工作依赖(job.cpp/pas)
- 题目 英雄 (BFS)
- 状态压缩DP codeforces 244 Problem C. The Brand New Function 和 codeforces 165 E. Compatible Numbers
- codeforces 16 Problem E fish
- Codeforces Round332 部分题解
- CodeForces 603A_Alternative Thinking (DP)