whust2016 warm up A ||codeforces 682 A. Alyona and Numbers (计数问题,水)

cf682A题目链接

题意:两个数组,分别为1..n和1..m。。。从两个数组中各取一个,问和能被5整除的方案数。。。

思路:傻逼题。。。统计%5。。。然后乘法原理。。

/* ***********************************************
Author :111qqz
Created Time :2016年07月18日 星期一 12时32分22秒
File Name :code/2016whust/A.cpp
************************************************ */
 1#include <cstdio>
 2#include <cstring>
 3#include <iostream>
 4#include <algorithm>
 5#include <vector>
 6#include <queue>
 7#include <set>
 8#include <map>
 9#include <string>
10#include <cmath>
11#include <cstdlib>
12#include <ctime>
13#define fst first
14#define sec second
15#define lson l,m,rt<<1
16#define rson m+1,r,rt<<1|1
17#define ms(a,x) memset(a,x,sizeof(a))
18typedef long long LL;
19#define pi pair < int ,int >
20#define MP make_pair
 1using namespace std;
 2const double eps = 1E-8;
 3const int dx4[4]={1,0,0,-1};
 4const int dy4[4]={0,-1,1,0};
 5const int inf = 0x3f3f3f3f;
 6const int N=1E6+7;
 7int n,m;
 8LL a[N],b[N];
 9int main()
10{
11	#ifndef  ONLINE_JUDGE 
12	freopen("code/in.txt","r",stdin);
13  #endif
 1	cin>>n>>m;
 2	ms(a,0);
 3	ms(b,0);
 4	for ( int i = 1 ; i <= n ; i++)
 5	{
 6	    int x = i % 5;
 7	    a[x]++;
 8	}
 9	for ( int i = 1 ; i <= m ; i++)
10	{
11	    int x = i % 5;
12	    b[x]++;
13	}
14	LL ans = 0;
15	ans = a[0]*b[0]+a[1]*b[4]+a[2]*b[3]+a[3]*b[2]+a[4]*b[1];
16	cout<<ans<<endl;
1  #ifndef ONLINE_JUDGE  
2  fclose(stdin);
3  #endif
4    return 0;
5}