A.A Math Problem

 #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
inline ll read(){
int x=,f=;char ch=getchar();
while(ch>''||ch<''){if(ch=='-')f=-;ch=getchar();}
while(ch>=''&&ch<=''){x=x*+ch-'';ch=getchar();}
return x*f;
} /***********************************************************/ const int maxn = 1e5+;
ll a[maxn]; void init(){
for(ll i = ;i <= ;i++){
a[i] = ;
for(ll j = ;j <= i;j++){
a[i] *= i;
}
//cout << i << " :" << a[i] << endl;
}
} int main(){
init();
ll n;
while(~scanf("%lld", &n)){
int ans = ;
for(ll i = ;i <= ;i++){
if(n >= a[i])
ans++;
else break;
}
cout << ans << endl;
}
return ;
}

G.Duizi and Shunzi

 #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
inline ll read(){
int x=,f=;char ch=getchar();
while(ch>''||ch<''){if(ch=='-')f=-;ch=getchar();}
while(ch>=''&&ch<=''){x=x*+ch-'';ch=getchar();}
return x*f;
} /***********************************************************/ const int maxn = 1e6+;
int a[maxn]; int main(){
int n;
while(~scanf("%d", &n)){
memset(a, , sizeof(a));
for(int i = ;i <= n;i++){
int x;
x = read();
a[x]++;
}
int ans = ;
for(int i = ;i <= n;i++){
ans += a[i]/;
a[i] %= ;
if(i+ <= n){
if(a[i] && a[i+]% && a[i+]){
ans++;
a[i]--;a[i+]--;a[i+]--;
}
} }
printf("%d\n", ans);
}
return ;
}
05-18 05:39