- C++
JSPX
- 2022-12-5 12:32:37 @
JSPX
9 条评论
-
chjshen 教练 LV 5 SU @ 2022-12-5 17:01:52
#include<cstdio> #include<iostream> using namespace std; const int N = 1000005; bool isprime[N]; int pri[N][10]; int a[N],f[N],p[N]; int n,m,ans; void initInput(void) { // init primes for (int i=2;i<=1000000;i++) if (!isprime[i]) { pri[i][++pri[i][0]]=i; for (int j=2;j<=1000000/i;j++) { pri[i*j][++pri[i*j][0]]=i; isprime[i*j]=true; } } // input scanf("%d",&n); for (int i=1;i<=n;i++) scanf("%d",&a[i]); } int mymax(int x,int y) { return (x > y ? x : y); } void handle(void) { for (int i=1;i<=n;i++) { f[i]=1; for(int j=1;j<=pri[a[i]][0];j++) f[i]=mymax(f[i],p[pri[a[i]][j]]+1); for(int j=1;j<=pri[a[i]][0];j++) p[pri[a[i]][j]]=f[i]; } for (int i=1;i<=n;i++) ans=mymax(ans,f[i]); printf("%d",ans); } int main(void) { initInput(); handle(); return 0; }
-
2022-12-5 16:25:38@
#include<iostream> #include<cstdio> #include<algorithm> using namespace std; const int INF=-0x3F3F3F3F; int n,m,a[1101],a1[1101],a2[1101],l1,l2,x1,x2,sum,p,ans=INF,t; void initInput(void) { int i; scanf("%d%d",&n,&m); for(i=1;i<=n;i++) scanf("%d",&a[i]); } void handle(void) { int i,j,k; for(i=1;i<=n;i++){ l1=0,l2=n,sum=0; for(j=1;j<=n;j++) a2[j]=a[j]; sort(a2+1,a2+1+n); for(j=i;j<=n;j++){ sum=0; for(k=1;k<=l2;k++) if(a2[k]==a[j]) break; p=k; for(k=p+1;k<=l2;k++) a2[k-1]=a2[k]; int key=a[j]; t=l1; while(t>0&&a1[t]>key){ a1[t+1]=a1[t]; t--; } l1++,l2--; a1[t+1]=key; for(k=1;k<=l1;k++) sum+=a1[k]; x1=1,x2=l2,t=0; while(t<m&&x1<=l1&&x2>=1&&a1[x1]<a2[x2]){ sum+=(a2[x2]-a1[x1]); t++,x1++,x2--; } ans=max(ans,sum); } } } int main(void) { initInput(); handle(); printf("%d",ans); return 0; }
-
2022-12-5 16:07:31@
#include<iostream> #include<cstdio> #include<map> using namespace std; int a, b, c, d; map<long long, int> abmp, cdmp; void initInput(void) { cin >> a >> b >> c >> d; for(int x1 = -100; x1 <= 100; x1++) { if(x1 == 0)x1++; for(int x2 = -100; x2 <= 100; x2++) { if(x2 == 0) x2++; long long temab = a * x1 * x1 + b * x2 * x2; abmp[temab]++; } } for(int x3 = -100; x3 <= 100; x3++) { if(x3 == 0)x3++; for(int x4 = -100; x4 <= 100; x4++) { if(x4 == 0) x4++; long long tempcd = c * x3 * x3 + d * x4 * x4; cdmp[tempcd]++; } } } void handle() { int ans = 0; for(auto ab:abmp) { int tans = 0; for(auto cd:cdmp) { if(ab.first + cd.first == 0) { tans += (ab.second * cd.second); } } ans += tans; } cout << ans << endl; } int main(void) { initInput(); handle(); return 0; }
-
2022-12-5 16:06:56@
t2 正解:
#include<iostream> #include<cstdio> #include<map> using namespace std; int a, b, c, d; map<long long, int> abmp, cdmp; void initInput(void) { cin >> a >> b >> c >> d; for(int x1 = -100; x1 <= 100; x1++) { if(x1 == 0)x1++; for(int x2 = -100; x2 <= 100; x2++) { if(x2 == 0) x2++; long long temab = a * x1 * x1 + b * x2 * x2; abmp[temab]++; } } for(int x3 = -100; x3 <= 100; x3++) { if(x3 == 0)x3++; for(int x4 = -100; x4 <= 100; x4++) { if(x4 == 0) x4++; long long tempcd = c * x3 * x3 + d * x4 * x4; cdmp[tempcd]++; } } } void force_solve() { int ans = 0; for(int x1 = -100; x1 <= 100; x1++) { if(x1 == 0) x1++; for(int x2 = -100; x2 <= 100; x2++) { if(x2 == 0) x2++; for(int x3 = -100; x3 <= 100; x3++) { if(x3 == 0) x3++; long long temp = 0 - 1LL * a * x1 * x1 + 1LL * b * x2 * x2 + 1LL * c * x3 * x3; long long temx = temp; if(d != 0) temx = temp / d; else { if(temp == 0) { ans += 200; break; } else { continue; } } // if(temx % 2) continue; if(temx <= 0) continue; if(temx > 10000) continue; if(d * temx + temp == 0) ans++; } } } cout << ans << endl; } void handle() { int ans = 0; for(auto ab:abmp) { int tans = 0; for(auto cd:cdmp) { if(ab.first + cd.first == 0) { tans += (ab.second * cd.second); } } ans += tans; } cout << ans << endl; } int main(void) { initInput(); handle(); // force_solve(); return 0; }
-
2022-12-5 16:00:12@
t2:暴力,不知道能得分不?
#include<iostream> #include<cstdio> #include<map> using namespace std; int a, b, c, d; map<long long, int> abmp, cdmp; void initInput(void) { cin >> a >> b >> c >> d; for(int x1 = -100; x1 <= 100; x1++) { for(int x2 = -100; x2 <= 100; x2++) { long long temab = a * x1 * x1 + b * x2 * x2; abmp[temab]++; } } for(int x3 = -100; x3 <= 100; x3++) { for(int x4 = -100; x4 <= 100; x4++) { long long tempcd = c * x3 * x3 + d * x4 * x4; cdmp[tempcd]++; } } } void force_solve() { int ans = 0; for(int x1 = -100; x1 <= 100; x1++) { if(x1 == 0) x1++; for(int x2 = -100; x2 <= 100; x2++) { if(x2 == 0) x2++; for(int x3 = -100; x3 <= 100; x3++) { if(x3 == 0) continue; long long temp = 0 - 1LL * a * x1 * x1 + 1LL * b * x2 * x2 + 1LL * c * x3 * x3; long long temx = temp; if(d != 0) temx = temp / d; else { if(temp == 0) { ans += 200; break; } else { continue; } } // if(temx % 2) continue; if(temx <= 0) continue; if(temx > 10000) continue; if(d * temx + temp == 0) ans++; } } } cout << ans << endl; } void handle() { int ans = 0; for(auto ab:abmp) { cout << ab.first << " " << ab.second << endl; int tans = 0; for(auto cd:cdmp) { if(ab.first + cd.first == 0) { tans += (ab.second * cd.second); } } ans += tans; } cout << ans << endl; } int main(void) { initInput(); // handle(); force_solve(); return 0; }
-
2022-12-5 15:26:54@
t4:
#include using namespace std; bool isprime[1000005]; int pri[1000005][10]; int a[1000005],f[1000005],p[1000005]; int n,m,ans; int max(int x,int y){ if (x>y) return x; return y; } int main(){
for (int i=2;i<=1000000;i++) if (!isprime[i]){ pri[i][++pri[i][0]]=i; for (int j=2;j<=1000000/i;j++){ pri[i*j][++pri[i*j][0]]=i; isprime[i*j]=true; } } scanf("%d",&n); for (int i=1;i<=n;i++) scanf("%d",&a[i]); for (int i=1;i<=n;i++){ f[i]=1; for (int j=1;j<=pri[a[i]][0];j++) f[i]=max(f[i],p[pri[a[i]][j]]+1); for (int j=1;j<=pri[a[i]][0];j++) p[pri[a[i]][j]]=f[i]; } for (int i=1;i<=n;i++) ans=max(ans,f[i]); printf("%d",ans); return 0;
}
-
2022-12-5 15:04:22@
#include<iostream> #include<cstdio> #include<algorithm> using namespace std; const int INF=-0x3F3F3F3F; int n,m,a[1101],a1[1101],a2[1101],l1,l2,x1,x2,sum,p,ans=INF,t; int main(){ int i,j,k; scanf("%d%d",&n,&m); for(i=1;i<=n;i++) scanf("%d",&a[i]); for(i=1;i<=n;i++){ l1=0,l2=n,sum=0; for(j=1;j<=n;j++) a2[j]=a[j]; sort(a2+1,a2+1+n); for(j=i;j<=n;j++){ sum=0; for(k=1;k<=l2;k++) if(a2[k]==a[j]) break; p=k; for(k=p+1;k<=l2;k++) a2[k-1]=a2[k]; int key=a[j]; t=l1; while(t>0&&a1[t]>key){ a1[t+1]=a1[t]; t--; } l1++,l2--; a1[t+1]=key; for(k=1;k<=l1;k++) sum+=a1[k]; x1=1,x2=l2,t=0; while(t<m&&x1<=l1&&x2>=1&&a1[x1]<a2[x2]){ sum+=(a2[x2]-a1[x1]); t++,x1++,x2--; } ans=max(ans,sum); } } printf("%d",ans); return 0; }
-
2022-12-5 14:54:51@
t3
#include<bits/stdc++.h> using namespace std; const int oo=-0x3F3F3F3F; int n,m,a[1101],a1[1101],a2[1101],l1,l2,x1,x2,sum,p,ans=oo,t; int main(){ int i,j,k; scanf("%d%d",&n,&m); for(i=1;i<=n;i++) scanf("%d",&a[i]); for(i=1;i<=n;i++){ l1=0,l2=n,sum=0; for(j=1;j<=n;j++) a2[j]=a[j]; sort(a2+1,a2+1+n); for(j=i;j<=n;j++){ sum=0; for(k=1;k<=l2;k++) if(a2[k]==a[j]) break; p=k; for(k=p+1;k<=l2;k++) a2[k-1]=a2[k]; int key=a[j]; t=l1; while(t>0&&a1[t]>key){ a1[t+1]=a1[t]; t--; } l1++,l2--; a1[t+1]=key; for(k=1;k<=l1;k++) sum+=a1[k]; x1=1,x2=l2,t=0; while(t<m&&x1<=l1&&x2>=1&&a1[x1]<a2[x2]){ sum+=(a2[x2]-a1[x1]); t++,x1++,x2--; } ans=max(ans,sum); }
} printf("%d",ans); fclose(stdin);fclose(stdout); return 0;
}
-
2022-12-5 14:50:45@
t1:
#include<iostream> #include<cstdio> using namespace std; int a, b, d, y, m; void initInput(void) { cin >> d >> y >> m; cin >> a >> b; } void handle() { int t = d; if(m < 9) t++, m = 9; if(b < 9) { t += (a - y - 1); } else { t += (a - y); } if(t <= 12) cout << t << endl; else if(t > 12 && t <= 15) cout << "college" << endl; else if(t > 15) cout << "graduate" << endl; } int main(void) { initInput(); handle(); return 0; }
- 1