ちょうしのった
JOIとか解くつもりだったはずなのにビッグウェーブとかに乗っかってたりしたらいつの間にか簡単な問題を書くだけの作業になってた・・・
0093
やるだけ
#include <cstdio> #include <vector> using namespace std; int main() { bool flag=false; int a, b; while (scanf("%d%d",&a,&b)) { if (!a&&!b) break; if (flag) puts(""); flag=true; vector<int> leap; for (int i=a; i<=b; i++) { if (i%4==0&&(i%100!=0||i%400==0)) { leap.push_back(i); } } if (leap.size()==0) puts("NA"); else { for (int i=0; i<leap.size(); i++) printf("%d\n",leap[i]); } } }
0160
やるだけ
#include <cstdio> int main() { int n, x, y, h, w; while (scanf("%d",&n)) { if (!n) break; int res=0; for (int i=0; i<n; i++) { scanf("%d%d%d%d",&x,&y,&h,&w); int sum=x+y+h; if (sum<=60&&w<=2) res+=600; else if (sum<=80&&w<=5) res+=800; else if (sum<=100&&w<=10) res+=1000; else if (sum<=120&&w<=15) res+=1200; else if (sum<=140&&w<=20) res+=1400; else if (sum<=160&&w<=25) res+=1600; } printf("%d\n",res); } }
0161
#include <cstdio> #include <algorithm> using namespace std; typedef long long ll; struct team { ll name, time; }; bool comp(const team& a, const team& b) { return a.time<b.time; }; team t[1000000]; int main() { int n; while (scanf("%d",&n)) { if (!n) break; for (int i=0; i<n; i++) { scanf("%lld",&t[i].name); int a,b,c,d,e,f,g,h;scanf("%d%d%d%d%d%d%d%d",&a,&b,&c,&d,&e,&f,&g,&h); t[i].time=(a+c+e+g)*60+b+d+f+h; } sort(t, t+n, comp); printf("%lld\n%lld\n%lld\n",t[0].name,t[1].name,t[n-2].name); } }
0195
#include <cstdio> #include <algorithm> using namespace std; struct map {int n, s; }; bool comp(const map& a, const map& b) { return a.s>b.s; } map x[5]; int main() { int s1, s2; while (scanf("%d%d",&s1,&s2)) { if (!s1&&!s2) break; x[0]=(map){0,s1+s2}; for (int i=1; i<5; i++) { scanf("%d%d",&s1,&s2); x[i]=(map){i,s1+s2}; } sort(x,x+5,comp); printf("%c %d\n",x[0].n+'A',x[0].s); } }
1129
#include <cstdio> #include <stack> #include <queue> using namespace std; int main() { int n, r; while (scanf("%d%d",&n,&r)) { if (!n&&!r) break; deque<int> deq; for (int i=n; i>=1; i--) deq.push_back(i); for (int i=0; i<r; i++) { int p, c; scanf("%d%d",&p,&c); stack<int> ue, shita; for (int j=0; j<p-1; j++) { ue.push(deq[0]); deq.pop_front(); } for (int j=0; j<c; j++) { shita.push(deq[0]); deq.pop_front(); } while (!ue.empty()) { deq.push_front(ue.top()); ue.pop(); } while (!shita.empty()) { deq.push_front(shita.top()); shita.pop(); } // for (int i=0; i<n; i++) printf("%d%c",deq[i],i==n-1?'\n':' '); // puts(""); } printf("%d\n",deq[0]); } }
1130
#include <cstdio> #include <iostream> #include <map> #include <queue> #include <string> using namespace std; typedef pair<int, int> P; int w, h; string f[20]; int dx[4]={-1,1,0,0}; int dy[4]={0,0,-1,1}; bool isin(int x, int y) { return x>=0&&x<h&&y>=0&&y<w; } int main() { while (scanf("%d%d",&w,&h)) { if (!w&&!h) break; int sx=-1,sy=-1; for (int i=0; i<h; i++) { cin>>f[i]; for (int j=0; j<w; j++) if (f[i][j]=='@') { sx=i; sy=j; f[i][j]='#'; } } queue<P> que; que.push(P(sx,sy)); int res=1; while (!que.empty()) { int x=que.front().first, y=que.front().second; que.pop(); for (int i=0; i<4; i++) { int nx=x+dx[i], ny=y+dy[i]; if (isin(nx,ny)&&f[nx][ny]=='.') { que.push(P(nx,ny)); f[nx][ny]='#'; res++; } } } printf("%d\n",res); } }
0144
#include <cstdio> #include <climits> #include <vector> #include <algorithm> #define inf INT_MAX/2 using namespace std; int ok[100][100]; int main() { int n; scanf("%d",&n); for (int i=0; i<n; i++) for (int j=0; j<n; j++) ok[i][j]=inf; for (int i=0; i<n; i++) { int r,k; scanf("%d%d",&r,&k); for (int j=0; j<k; j++) { int t; scanf("%d",&t); ok[r-1][t-1]=1; } } for (int k=0; k<n; k++) { for (int i=0; i<n; i++) { for (int j=0; j<n; j++) { ok[i][j]=min(ok[i][j],ok[i][k]+ok[k][j]); } } } int p; scanf("%d",&p); for (int i=0; i<p; i++) { int s,d,v; scanf("%d%d%d",&s,&d,&v); if (v<=ok[s-1][d-1]) puts("NA"); else printf("%d\n",ok[s-1][d-1]+1); } }
1200
#include <cstdio> #include <vector> #include <algorithm> using namespace std; int isp[1000000]; vector<int> p; int main() { fill(isp, isp+1000000, 1); isp[0]=isp[1]=0; for (int i=2; i<1000000; i++) { if (!isp[i]) continue; p.push_back(i); for (int j=i*2; j<1000000; j+=i) isp[j]=0; } int n; while (scanf("%d",&n)) { if (!n) break; int res=0; for (int i=0; i<p.size()&&n-p[i]>=p[i];i++) { if (isp[n-p[i]]) res++; } printf("%d\n",res); } }