标签:
| Time Limit: 3000MS | Memory Limit: 32768KB | 64bit IO Format: %I64d & %I64u |
Description
Input
Output
Sample Input
2 1 3
Sample Output
0 1
/*
Author: 2486
Memory: 1416 KB Time: 2823 MS
Language: G++ Result: Accepted
*/
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
using namespace std;
typedef long long LL;
const int maxn=1e5;
int t;
LL n;
int main() {
scanf("%d",&t);
while(t--) {
scanf("%I64d",&n);
if(n==0||n==1) {
printf("0\n");
continue;
}
int cnt=0;
for(int i=1; i<=sqrt(n); i++) {
if((n+1)%(i+1)==0&&(n+1)/(i+1)>=i+1)cnt++;
}
printf("%d\n",cnt);
}
}/*
Author: 2486
Memory: 1592 KB Time: 46 MS
Language: G++ Result: Accepted
*/
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
typedef long long LL;
const int maxn=100000+5;
LL prime[maxn];
bool vis[maxn];
int T,cnt;
LL N;
void primes() { //初始化素数列表
cnt=0;
for(int i=2; i<maxn; i++) {
if(vis[i])continue;
prime[cnt++]=i;
for(int j=i*2; j<maxn; j+=i) {
vis[j]=true;
}
}
}
void solve(LL n) {
LL ans=1;
for(int i=0; prime[i]*prime[i]<=n; i++) {
if(n%prime[i]==0) {
int s=0;
while(n%prime[i]==0)n/=prime[i],s++;
ans*=(s+1);
}
if(n==1)break;
}
if(n>1)ans*=2;
printf("%I64d\n",(ans+1)/2-1);
}
int main() {
primes();
scanf("%d",&T);
while(T--) {
scanf("%I64d",&N);
N++;
solve(N);
}
return 0;
}
版权声明:本文为博主原创文章,未经博主允许不得转载。
HDU 2601An easy problem-素数的运用,暴力求解
标签:
原文地址:http://blog.csdn.net/qq_18661257/article/details/47103257