HDU 1215 七夕节 数论
生活随笔
收集整理的這篇文章主要介紹了
HDU 1215 七夕节 数论
小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
七夕節(jié) Time Limit:1000MS?????Memory Limit:32768KB?????64bit IO Format:%I64d & %I64u
人們紛紛來(lái)到告示前,都想知道誰(shuí)才是自己的另一半.告示如下:?
數(shù)字N的因子就是所有比N小又能被N整除的所有正整數(shù),如12的因子有1,2,3,4,6.?
你想知道你的另一半嗎??
#include <iostream> #include <cstring> #include <cstdio> #include <algorithm> #include <queue> #include <vector> #include <iomanip> #include <math.h> using namespace std; #define FIN freopen("input.txt","r",stdin); #define INF 0x3f3f3f3f #define lson l,m,rt<<1 #define rson m+1,r,rt<<1|1 typedef long long LL;LL p[500005];int main() {//FINfor(int i=2;i<=500000;i++)for(int j=i;j<=500000;j+=i)p[j]+=i;LL n,t;scanf("%lld",&t);while(t--){scanf("%lld",&n);printf("%lld\n",p[n]-n+1);}}
Description
七夕節(jié)那天,月老來(lái)到數(shù)字王國(guó),他在城門上貼了一張告示,并且和數(shù)字王國(guó)的人們說(shuō):"你們想知道你們的另一半是誰(shuí)嗎?那就按照告示上的方法去找吧!"?人們紛紛來(lái)到告示前,都想知道誰(shuí)才是自己的另一半.告示如下:?
數(shù)字N的因子就是所有比N小又能被N整除的所有正整數(shù),如12的因子有1,2,3,4,6.?
你想知道你的另一半嗎??
Input
輸入數(shù)據(jù)的第一行是一個(gè)數(shù)字T(1<=T<=500000),它表明測(cè)試數(shù)據(jù)的組數(shù).然后是T組測(cè)試數(shù)據(jù),每組測(cè)試數(shù)據(jù)只有一個(gè)數(shù)字N(1<=N<=500000).?Output
對(duì)于每組測(cè)試數(shù)據(jù),請(qǐng)輸出一個(gè)代表輸入數(shù)據(jù)N的另一半的編號(hào).?Sample Input
3 2 10 20Sample Output
1 8 22#include <iostream> #include <cstring> #include <cstdio> #include <algorithm> #include <queue> #include <vector> #include <iomanip> #include <math.h> using namespace std; #define FIN freopen("input.txt","r",stdin); #define INF 0x3f3f3f3f #define lson l,m,rt<<1 #define rson m+1,r,rt<<1|1 typedef long long LL;LL p[500005];int main() {//FINfor(int i=2;i<=500000;i++)for(int j=i;j<=500000;j+=i)p[j]+=i;LL n,t;scanf("%lld",&t);while(t--){scanf("%lld",&n);printf("%lld\n",p[n]-n+1);}}
轉(zhuǎn)載于:https://www.cnblogs.com/Hyouka/p/5721550.html
總結(jié)
以上是生活随笔為你收集整理的HDU 1215 七夕节 数论的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: win8 远程桌面时提示凭证不工作问题的
- 下一篇: Android — 使用 SharedP