CF题目求问Genealogy of aliens
  • 板块题目总版
  • 楼主flowercode
  • 当前回复0
  • 已保存回复0
  • 发布时间2024/7/27 21:26
  • 上次更新2024/7/27 23:42:48
查看原帖
CF题目求问Genealogy of aliens
1236674
flowercode楼主2024/7/27 21:26

原题

The planet Venus is known for its toxic atmosphere and infernal temperatures, where apparently any civilization would be unable to live and thrive. However, records of an ancient civilization (the "Venirics") that inhabited Venus millions of years ago have been recently detected on this planet.

Faced with this surprising discovery, the Union of Solar Planets (USP) decided to send to this planet the only specialist capable of retrieving these records and revealing more details about the history of the Venutian civilization: the space archaeologist Otávio.

In his extensive research, Otávio discovered surprising facts about the generations of Venirics:

  • Generation 00 of the Venirics was composed of exactly a≥1a \geq 1 inhabitants.
  • In the life cycle of a Veniric capable of reproduction, they have exactly r>1 offspring through asexual reproduction. The value of rr is the same for Venirics of any generation. That is, if all aa Venirics from generation 00 were capable of reproduction, then generation 11 was composed of exactly arar Venirics, and so on.
  • Due to a genetic reason still unexplained, all individuals of a certain generation m≥0m \geq 0 were unable to reproduce, but all individuals up to the previous generation were capable of reproduction. Thus, the Venirics civilization ended after the death of individuals from generation mm.

The only intact record that Otávio found about the size of the historical Venirics population was its total number (i.e., the sum of the sizes of all populations from generation 00 to generation mm), but he was unable to deduce anything about the values of aa, rr, and mm, and therefore asked for help from Marcelo, the space computer scientist.

Marcelo was also unable to deduce the values of aa, rr, and mm from nn, as he wisely noticed that different values of these parameters could have led to the same value of nn. The only thing he knows is that there are not many possibilities for the sizes of the generations given nn, and he wishes to determine how many there are.

Since returning from the toxicity of Venus, however, he can no longer type, and so he asked you to write a program that answers the question for him.

Input

A single integer nn (1≤n≤1091 \leq n \leq 10^9), the total historical population of the Venirics.

Input

A single integer nn (1≤n≤1091 \leq n \leq 10^9), the total historical population of the Venirics.

Examples

input

7

output

3

input

1000000000

output

101

#include<iostream>
#include<map>
#include<cmath>
#define ll long long 
using namespace std;
int main(){
    ll n;
    cin >> n;
    ll ans = 0;
    //求m = 2时的情况,即n除了1以外的因数个数
    if(n >= 2){
        for(int i = 2; i*i <= n ;++i){
            if(i * i == n){
                ans += 1;
                continue;
            }
            if(n % i == 0)
            {
                ans += 2;
            }
        }
        ans ++ ;
    }
    //枚举 r,m
    if(n >= 7){
    for(ll r = 2 ; r*r <= n ; ++r){
        ll gcd = 1 + r ;
        for(ll m = 2; m <= n  ; ++m){
            gcd = gcd * r + 1;
            if(gcd > n)break;
            if( gcd != 0 && n % gcd == 0) {
                ++ans;
            }
        }
        }
    }
    // m = 0 时只有一种情况,答案加上1.
     cout << ans + 1;
     return 0;
}

我的代码输入1000000000,输出102,找不到原因

2024/7/27 21:26
加载中...