前言
开始做四面八方扣来的题
成绩
RankRankRank | PersonPersonPerson | ScoreScoreScore | AAA | BBB | CCC |
---|---|---|---|---|---|
111 | 2017zyc2017zyc2017zyc | 160160160 | 707070 | 303030 | 606060 |
222 | 2017wyc2017wyc2017wyc | 140140140 | 808080 | 101010 | 505050 |
333 | 2017lrz2017lrz2017lrz | 140140140 | 404040 | 100100100 | 000 |
444 | 2017xjq2017xjq2017xjq | 100100100 | 707070 | 303030 | 000 |
555 | 2017xxy2017xxy2017xxy | 100100100 | 707070 | 303030 | 000 |
666 | 2015gjh2015gjh2015gjh | 100100100 | 000 | 000 | 100100100 |
777 | 2017hjq2017hjq2017hjq | 707070 | 404040 | 303030 | 000 |
888 | 2017lw2017lw2017lw | 707070 | 404040 | 303030 | 000 |
999 | 2015yjy2015yjy2015yjy | 707070 | 404040 | 303030 | 000 |
101010 | 2015zyf2015zyf2015zyf | 707070 | 404040 | 000 | 303030 |
正题
T1:nssl1194−T1:nssl1194-T1:nssl1194−春思【逆元,等比数列,约数】
更之前一道题一样的:
https://blog.csdn.net/Mr_wuyongcong/article/details/82502158
T2:nssl1195−T2:nssl1195-T2:nssl1195−健美猫【?????????】
博客链接:
https://blog.csdn.net/Mr_wuyongcong/article/details/83212915
T3:nssl1196−T3:nssl1196-T3:nssl1196−摘果子【树形依赖背包,dp,dp,dp】
博客链接:
https://blog.csdn.net/Mr_wuyongcong/article/details/83210493
someofcodesome\ of\ codesome of code
T1 80分code
#include<cstdio>
#include<algorithm>
#define mod 9901
#define ll long long
using namespace std;
ll pr[50],c[50],a,b,cnt,ans;
void prime(ll a)
{for(ll i=2;i*i<=a;i++){if(!(a%i)){pr[++cnt]=i;while(!(a%i)) c[cnt]++,a/=i;}}if(a!=1) pr[++cnt]=a,c[cnt]=1;
}
ll power(ll a,ll b)
{ll ans=1;while(b){if(b&1) ans=(ans*a)%mod;a=(a*a)%mod;b>>=1;}return ans;
}
int main()
{scanf("%lld%lld",&a,&b);prime(a);ans=1;for(ll i=1;i<=cnt;i++){ll inx=power(pr[i]-1,mod-2);if(!inx){ans=ans*((c[i]*b+1)%mod)%mod;continue;}ll k=(power(pr[i],c[i]*b+1)+mod-1)%mod*inx%mod;ans=ans*k%mod;}printf("%lld",ans);
}
T2 10分code
#include<cstdio>
#include<algorithm>
#define N 2000010
using namespace std;
int n,s[N*2],ans,sum;
int main()
{scanf("%d",&n);for(int i=1;i<=n;i++)scanf("%d",&s[i]),s[i+n]=s[i];ans=1;int i=2;while(i<=2*n){if(s[i]<s[ans]){ans=i;i++;continue;}if(s[i]>s[ans]){i++;continue;}int k=1;while(i+k<=2*n&&s[i+k]==s[ans+k]) k++;if(i+k>2*n) break;if(s[i]>s[i+k])ans=i+k;else if(s[ans+k]>s[i+k]) ans=i;i+=k+1;}for(i=ans;i<ans+n;i++)sum+=abs(s[i]-(i-ans+1));printf("%d",sum);
}
T3 50分code
#include<cstdio>
#include<algorithm>
#define N 2010
using namespace std;
struct node{int to,next;
}a[N];
int n,m,v[N],p[N],ls[N],f[N][N],tot,x,y;
void addl(int x,int y)
{a[++tot].to=y;a[tot].next=ls[x];ls[x]=tot;
}
void dp(int x,int fa)
{for(int i=ls[x];i;i=a[i].next){int y=a[i].to;if(y==fa) continue;dp(y,x);for(int j=m;j>=p[y];j--){for(int k=p[y];k<=j;k++)f[x][j]=max(f[x][j],f[x][j-k]+f[y][k]);}}for(int j=m;j>=p[x];j--)f[x][j]=f[x][j-p[x]]+v[x];
}
int main()
{scanf("%d%d",&n,&m);for(int i=1;i<=n;i++)scanf("%d%d",&v[i],&p[i]);for(int i=1;i<n;i++){scanf("%d%d",&x,&y);addl(x,y);addl(y,x);}dp(1,0);printf("%d",f[1][m]);
}
尾声
没了