日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

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

發布時間:2023/12/4 编程问答 42 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Codeforces Round #358 (Div. 2) A. Alyona and Numbers 水题 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

A. Alyona and Numbers

題目連接:

http://www.codeforces.com/contest/682/problem/A

Description

After finishing eating her bun, Alyona came up with two integers n and m. She decided to write down two columns of integers — the first column containing integers from 1 to n and the second containing integers from 1 to m. Now the girl wants to count how many pairs of integers she can choose, one from the first column and the other from the second column, such that their sum is divisible by 5.

Formally, Alyona wants to count the number of pairs of integers (x,?y) such that 1?≤?x?≤?n, 1?≤?y?≤?m and equals 0.

As usual, Alyona has some troubles and asks you to help.

Input

The only line of the input contains two integers n and m (1?≤?n,?m?≤?1?000?000).

Output

Print the only integer — the number of pairs of integers (x,?y) such that 1?≤?x?≤?n, 1?≤?y?≤?m and (x?+?y) is divisible by 5.

Sample Input

6 12

Sample Output

14

Hint

題意

給你n,m。然后告訴你1<=x<=n,1<=y<=m

然后問你(x+y)%5=0的方案有多少種

題解:

考慮余數。

兩個余數之和為0,那么有0+0,1+4,2+3,3+2,4+1這么五種組合,我可以O(n)或者O(5)統計出每個數的余數為i的有多少個。

然后再O(5)的求解答案就好了。

代碼

#include<bits/stdc++.h> using namespace std;long long num1[5]; long long num2[5]; int main() {long long n,m;cin>>n>>m;for(int i=0;i<5;i++){num1[i]=n/5;if(n%5>=i)num1[i]++;num2[i]=m/5;if(m%5>=i)num2[i]++;}num1[0]--,num2[0]--;long long ans = 0;ans = num1[0]*num2[0]+num1[1]*num2[4]+num1[2]*num2[3]+num1[3]*num2[2]+num1[4]*num2[1];cout<<ans<<endl; }

總結

以上是生活随笔為你收集整理的Codeforces Round #358 (Div. 2) A. Alyona and Numbers 水题的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。