#10746. 数论第五题(NOIP2012)

数论第五题(NOIP2012)

第五题(NOIP2012)

#include<iostream>
using namespace std;
int n,i,ans;
int gcd(int a,int b){
    if(a%b==0)
        return b;
    else
        return gcd(b,a%b);
}
int main(){
    cin>>n;
    ans=0;
    for(i=1;i<=n;i++)
        if(gcd(n,i)==i)ans++;
    cout<<ans<<endl;
}
  1. 【判断题】将n定义为double类型,程序的输出结果不变。
    {{ select(1) }}
  • 正确
  • 错误
  1. 【判断题】输入一个正整数,输出结果不可能不大于1。
    {{ select(2) }}
  • 正确
  • 错误
  1. 【判断题】输入100000000000,输出结果为144。
    {{ select(3) }}
  • 正确
  • 错误
  1. 【判断题】第12行可改为scanf("%d",&n);
    {{ select(4) }}
  • 正确
  • 错误
  1. 【选择题】输入120,输出为( )。
    {{ select(5) }}
  • 15
  • 16
  • 18
  • 14
  1. 【选择题】该算法时间复杂度为( )。
    {{ select(6) }}
  • O(n)
  • O(nlogn)
  • O(n\sqrt{n})
  • O(n²)