1. 程式人生 > 其它 >10.6模擬賽

10.6模擬賽

 1 #include<bits/stdc++.h>
 2 #define ll long long
 3 using namespace std;
 4 ll n,ans;
 5 int main()
 6 {
 7     freopen("star.in","r",stdin);
 8     freopen("star.out","w",stdout);
 9     scanf("%lld",&n);
10     if(n<=7) ans=1ll*5*(n+2);
11     else ans=1ll*10*(n-3);
12     printf("%lld\n
",ans); 13 return 0; 14 }
 1 #include<bits/stdc++.h>
 2 #define ll long long
 3 using namespace std;
 4 ll n,dp[11];
 5 int main()
 6 {
 7     freopen("alice.in","r",stdin);
 8     freopen("alice.out","w",stdout);
 9     scanf("%lld",&n);
10     dp[6]=n/100,n%=100;
11     while(n>=50) n-=50
,++dp[5]; 12 while(n>=20) n-=20,++dp[4]; 13 while(n>=10) n-=10,++dp[3]; 14 while(n>=5) n-=5,++dp[2]; 15 while(n>=1) n-=1,++dp[1]; 16 for(ll i=1;i<=6;++i) printf("%lld ",dp[i]); puts(""); 17 return 0; 18 }
 1 #include <bits/stdc++.h>
 2 #define ll long long
 3
const ll N=4e4+11,L=23,mod=1e9+7; 4 ll T,n,m,dp[L][L],ans; 5 char a[N],b[N]; 6 int main() 7 { 8 freopen("marisa.in", "r", stdin); 9 freopen("marisa.out", "w", stdout); 10 scanf("%lld%s%s",&T,a+1,b+1); 11 n=strlen(a+1),m=strlen(b+1),dp[0][0]=1; 12 for(ll i=1;i<=T;++i) { 13 for(ll j=n;j>=0;--j) for(ll k=m;k>=0;--k) { 14 ll t=24; t+=(j==n)+(k==m); 15 if(j<n && k<m && a[j+1]==b[k+1]) ++t; 16 (dp[j][k]*=t)%=mod; 17 if(k && a[j+1]!=b[k]) (dp[j][k]+=dp[j][k-1])%=mod; 18 if(j && a[j]!=b[k+1]) (dp[j][k]+=dp[j-1][k])%=mod; 19 if(j && k && a[j]==b[k]) (dp[j][k]+=dp[j-1][k-1])%=mod; 20 } 21 for(ll k=0;k<m;++k) (ans+=dp[n][k])%=mod; 22 } 23 printf("%lld\n", ans); 24 return 0; 25 }
 1 #pragma GCC optimize(2)
 2 
 3 #define FASTER
 4 #ifdef FASTER
 5 #pragma GCC diagnostic error "-std=c++11"
 6 #pragma GCC optimize(2)
 7 #pragma GCC optimize(3)
 8 #pragma GCC optimize("Ofast")
 9 #pragma GCC optimize("inline")
10 #pragma GCC optimize("-fgcse")
11 #pragma GCC optimize("-fgcse-lm")
12 #pragma GCC optimize("-fipa-sra")
13 #pragma GCC optimize("-ftree-pre")
14 #pragma GCC optimize("-ftree-vrp")
15 #pragma GCC optimize("-fpeephole2")
16 #pragma GCC optimize("-ffast-math")
17 #pragma GCC optimize("-fsched-spec")
18 #pragma GCC optimize("unroll-loops")
19 #pragma GCC optimize("-falign-jumps")
20 #pragma GCC optimize("-falign-loops")
21 #pragma GCC optimize("-falign-labels")
22 #pragma GCC optimize("-fdevirtualize")
23 #pragma GCC optimize("-fcaller-saves")
24 #pragma GCC optimize("-fcrossjumping")
25 #pragma GCC optimize("-fthread-jumps")
26 #pragma GCC optimize("-funroll-loops")
27 #pragma GCC optimize("-fwhole-program")
28 #pragma GCC optimize("-freorder-blocks")
29 #pragma GCC optimize("-fschedule-insns")
30 #pragma GCC optimize("inline-functions")
31 #pragma GCC optimize("-ftree-tail-merge")
32 #pragma GCC optimize("-fschedule-insns2")
33 #pragma GCC optimize("-fstrict-aliasing")
34 #pragma GCC optimize("-fstrict-overflow")
35 #pragma GCC optimize("-falign-functions")
36 #pragma GCC optimize("-fcse-skip-blocks")
37 #pragma GCC optimize("-fcse-follow-jumps")
38 #pragma GCC optimize("-fsched-interblock")
39 #pragma GCC optimize("-fpartial-inlining")
40 #pragma GCC optimize("no-stack-protector")
41 #pragma GCC optimize("-freorder-functions")
42 #pragma GCC optimize("-findirect-inlining")
43 #pragma GCC optimize("-fhoist-adjacent-loads")
44 #pragma GCC optimize("-frerun-cse-after-loop")
45 #pragma GCC optimize("inline-small-functions")
46 #pragma GCC optimize("-finline-small-functions")
47 #pragma GCC optimize("-ftree-switch-conversion")
48 #pragma GCC optimize("-foptimize-sibling-calls")
49 #pragma GCC optimize("-fexpensive-optimizations")
50 #pragma GCC optimize("-funsafe-loop-optimizations")
51 #pragma GCC optimize("inline-functions-called-once")
52 #pragma GCC optimize("-fdelete-null-pointer-checks")
53 #endif
54 
55 #include<bits/stdc++.h>
56 #define ll long long
57 #define pll pair<ll,ll>
58 using namespace std;
59 inline ll re_ad() {
60     char ch=getchar(); ll x=0,f=1;
61     while(ch<'0' || ch>'9') { if(ch=='-') f=-1; ch=getchar(); }
62     while('0'<=ch && ch<='9') x=(x<<1)+(x<<3)+ch-'0',ch=getchar();
63     return x*f;
64 }
65 
66 const ll N=2e5+11,inf=9e18;
67 ll n,k;
68 struct Node { ll x,y; }a[N];
69 inline ll Dist(Node A,Node B) { ll t=(A.x-B.x)*(A.x-B.x)+(A.y-B.y)*(A.y-B.y); return t>0?t:inf; }
70 inline bool cmp(Node A,Node B) { return Dist(A,a[n+1])>Dist(B,a[n+1]); }
71 priority_queue<pll>dg,xg;
72 
73 int main()
74 {
75     freopen("flower.in","r",stdin);
76     freopen("flower.out","w",stdout);
77     n=re_ad(),k=re_ad();
78     a[n+1].x=re_ad(),a[n+1].y=re_ad(),a[n+2].x=re_ad(),a[n+2].y=re_ad();
79     for(ll i=1;i<=n;++i) a[i].x=re_ad(),a[i].y=re_ad();
80     sort(a+1,a+n+1,cmp);
81     ll ans=inf,t=Dist(a[n+1],a[1]);
82     if(t>0) ans=min(ans,t);
83     for(ll i=1;i<=n;++i) {
84         ll r1=0; if(i<n) r1=Dist(a[n+1],a[i+1]);
85         xg.push(make_pair(-Dist(a[n+2],a[i]),i));
86         if(xg.size()>k) {
87             ll u=xg.top().first,v=xg.top().second;
88             xg.pop(),dg.push(make_pair(-u,v));
89         }
90         ll r2=0; if(!dg.empty()) r2=dg.top().first;
91         ll t=r1+r2;
92         if(t>0) ans=min(ans,r1+r2);
93 //        printf("%llu %llu\n",r1,r2);
94     }
95     printf("%lld\n",ans);
96     return 0;
97 }