百度之星初赛A hdu6108

1001

 小C的倍数问题

题意:中文题

思路:p-1的因子个数

AC代码:

#include "iostream"
#include "string.h"
#include "stack"
#include "queue"
#include "string"
#include "vector"
#include "set"
#include "map"
#include "algorithm"
#include "stdio.h"
#include "math.h"
#pragma comment(linker, "/STACK:102400000,102400000")
#define ll long long
#define endl ("\n")
#define bug(x) cout<<x<<" "<<"UUUUU"<<endl;
#define mem(a,x) memset(a,x,sizeof(a))
#define mp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define ft first
#define sd second
#define lrt (rt<<1)
#define rrt (rt<<1|1)
using namespace std;
const long long INF = 1e18+1LL;
const int inf = 1e9+1e8;
const int N=1e5+100;
const ll mod=1e9+7;

ll p,ans;
int main(){
    //ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
    int T; cin>>T;
    while(T--){
        cin>>p;
        ans=0;
        for(ll i=1; i*i<=p-1; ++i){
            if((p-1)%i==0){
                if((p-1)/i!=i) ans++;
                ans++;
            }
        }
        cout<<ans<<endl;
    }
    return 0;
}

 

posted on 2017-08-12 21:09  lazzzy  阅读(131)  评论(0编辑  收藏  举报

导航