Submission #11544845


Source Code Expand

Copy
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
//---------------------------------------------------------------------------------------------------
vector<ll> enumdiv(ll n) {
	vector<ll> S;
	for (ll i = 1; i*i <= n; i++) if (n%i == 0) { S.push_back(i); if (i*i != n) S.push_back(n / i); }
	sort(S.begin(), S.end());
	return S;
}
/*---------------------------------------------------------------------------------------------------
            ∧_∧
      ∧_∧  (´<_` )  Welcome to My Coding Space!
     ( ´_ゝ`) /  ⌒i     @hamayanhamayan0
    /   \     | |
    /   / ̄ ̄ ̄ ̄/  |
  __(__ニつ/     _/ .| .|____
     \/____/ (u ⊃
---------------------------------------------------------------------------------------------------*/














ll N;
//---------------------------------------------------------------------------------------------------
void _main() {
	cin >> N;
	set<ll> ans;

	auto ed1 = enumdiv(N);
	fore(d, ed1) if (2 <= d) {
		ll K = d;
		ll n = N;
		while (n % K == 0) n /= K;
		if ((n - 1) % K == 0) ans.insert(K);
	}

	auto ed2 = enumdiv(N - 1);
	fore(d, ed2) if (2 <= d) ans.insert(d);

	cout << ans.size() << endl;
}





Submission Info

Submission Time
Task F - Division or Subtraction
User hamayanhamayan
Language C++14 (GCC 5.4.1)
Score 600
Code Size 1891 Byte
Status AC
Exec Time 22 ms
Memory 384 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 600 / 600
Status
AC × 3
AC × 25
Set Name Test Cases
Sample sample_01, sample_02, sample_03
All hand_01, hand_02, hand_03, hand_04, random_01, random_02, random_03, random_04, random_05, random_06, random_07, random_08, random_09, random_10, random_11, random_12, random_13, random_14, random_15, random_16, random_17, random_18, sample_01, sample_02, sample_03
Case Name Status Exec Time Memory
hand_01 AC 22 ms 256 KB
hand_02 AC 19 ms 384 KB
hand_03 AC 1 ms 256 KB
hand_04 AC 3 ms 256 KB
random_01 AC 1 ms 256 KB
random_02 AC 1 ms 256 KB
random_03 AC 1 ms 256 KB
random_04 AC 17 ms 256 KB
random_05 AC 22 ms 256 KB
random_06 AC 22 ms 256 KB
random_07 AC 16 ms 256 KB
random_08 AC 9 ms 256 KB
random_09 AC 2 ms 256 KB
random_10 AC 2 ms 256 KB
random_11 AC 22 ms 256 KB
random_12 AC 16 ms 256 KB
random_13 AC 5 ms 256 KB
random_14 AC 10 ms 256 KB
random_15 AC 7 ms 256 KB
random_16 AC 18 ms 256 KB
random_17 AC 18 ms 256 KB
random_18 AC 9 ms 256 KB
sample_01 AC 1 ms 256 KB
sample_02 AC 1 ms 256 KB
sample_03 AC 13 ms 256 KB