2016 湖南省省赛 Problem A: 2016
生活随笔
收集整理的這篇文章主要介紹了
2016 湖南省省赛 Problem A: 2016
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
Problem A: 2016
Time Limit: 5 Sec Memory Limit: 128 MB
Submit: 296 Solved: 171
Description
給出正整數(shù) n 和 m,統(tǒng)計(jì)滿足以下條件的正整數(shù)對 (a,b) 的數(shù)量:
1. 1≤a≤n,1≤b≤m;
2. a×b 是 2016 的倍數(shù)。
Input
輸入包含不超過 30 組數(shù)據(jù)。
每組數(shù)據(jù)包含兩個整數(shù) n,m (1≤n,m≤109).
Output
對于每組數(shù)據(jù),輸出一個整數(shù)表示滿足條件的數(shù)量。
Sample Input
32 63
2016 2016
1000000000 1000000000
Sample Output
1
30576
7523146895502644
HINT
/*
真心菜,就水出來一個題......
任何一個數(shù)都能表示成n=a*2016+i,m=b*2016+j;
n*m=a*b*2016^2+a*2016*j+b*2016*i+i*j;
如果i*j是2016的倍數(shù)的話,那么n*m一定是2016的倍數(shù),
這樣在2016*2016的規(guī)模中遍歷出符合i*j%2016=0的數(shù),按照n中有多少個這樣的i,m中有多少這樣的j,然后相乘,累加起來就得到的區(qū)間中所有的數(shù)
*/
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#define MAXN 2016
using namespace std;
int main()
{
//freopen("in.txt","r",stdin);
//freopen("out.txt","w",stdout);
long long cur=;
long long n,m;
while(scanf("%lld%lld",&n,&m)!=EOF)
{
cur=;
for(int i=;i<=min((long long ),n);i++)
{
for(int j=;j<=min((long long ),m);j++)
{
if((i*j)%==)
{
//cout<<i<<" "<<j<<endl;
cur+=((n-i)/+)*((m-j)/+);
}
}
}
printf("%lld\n",cur);
}
return ;
}
/*
_ooOoo_
o8888888o
88" . "88
(| -_- |)
O\ = /O
____/`---'\____
.' \\| |// `.
/ \\||| : |||// \
/ _||||| -:- |||||- \
| | \\\ - /// | |
| \_| ''\---/'' | |
\ .-\__ `-` ___/-. /
___`. .' /--.--\ `. . __
."" '< `.___\_<|>_/___.' >'"".
| | : `- \`.;`\ _ /`;.`/ - ` : | |
\ \ `-. \_ __\ /__ _/ .-` / /
======`-.____`-.___\_____/___.-`____.-'======
`=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
I have a dream!A AC deram!!
orz orz orz orz orz orz orz orz orz orz orz
orz orz orz orz orz orz orz orz orz orz orz
orz orz orz orz orz orz orz orz orz orz orz */
總結(jié)
以上是生活随笔為你收集整理的2016 湖南省省赛 Problem A: 2016的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 创建TCP服务器和TCP客户端
- 下一篇: PCM存储格式 Intel 和 Moto