1 条题解
-
0
偶数一直减2,奇数减最小质数后一直减2
/***************************************** Note : ******************************************/ #include <queue> #include <math.h> #include <stack> #include <stdio.h> #include <iostream> #include <vector> #include <iomanip> #include <string.h> #include <algorithm> #define int long long #define IL inline const int N = 1e6+10; const int INF = 0x3f3f3f3f; using namespace std; IL int read() { char ch = getchar(); int f = 1, num = 0; while(ch>'9'||ch<'0') { if(ch=='-') f = -1; ch=getchar(); } while(ch>='0'&&ch<='9') num = num*10+ch-'0', ch = getchar(); return num*f; } int n,ans; signed main() { n=read(); if(n%2==0) printf("%lld\n",n/2); else { int fl=0; for(int i = 3;i*i<=n;i++) if(n%i==0) { n-=i,fl=1; break; } if(fl) printf("%lld\n",n/2+1); else puts("1"); } }
- 1
信息
- ID
- 2316
- 时间
- 1000ms
- 内存
- 256MiB
- 难度
- 9
- 标签
- 递交数
- 67
- 已通过
- 7
- 上传者