163 条题解
-
0zhe184324 LV 4 @ 2008-09-14 21:39:50
??
-
-12018-04-18 09:25:43@
#include <iostream>
#include <cstdio>using namespace std;
int y,m,d;
int day[13]={0,31,28,31,30,31,30,31,31,30,31,30,31};int main()
{cin>>y>>m>>d;
for (int i=1;i<=10000;i++)
{
if (y%4==0)
day[2]=29;
else day[2]=28;
d++;
if (d>day[m])
m++,d=1;
if (m==13)
m=1,y++;
}
cout<<y<<"-"<<m<<"-"<<d<<endl;
return 0;
} -
-22017-06-17 19:57:34@
哇,恐怕只有我一个人的代码这么奇葩了(逃,表示不会用运算符重载
#include<iostream> #include<map> #include<algorithm> using namespace std; typedef struct taotao{ int weight; int apple; }taotao; size_t num[100000]; int appleSize[100000]; map<int,size_t>myMap; int main(void) { int n,m; cin>>n>>m; for(int i=0;i<n;i++) { cin>>appleSize[i]; taotao* p=new taotao; num[i]=(size_t)p; } for(int i=0;i<m;i++) { int index; cin>>index; ((taotao*)num[i])->weight=index; myMap[index]=num[i]; } sort(appleSize,appleSize+n); map<int,size_t>::iterator iter=myMap.end(); int count1=0; for(int i=0;i<n;i++) { iter--; ((taotao*)(iter->second))->apple+=appleSize[n-i-1]; if(iter==myMap.begin()) iter=myMap.end(); } for(int i=0;i<m;i++) { cout<<((taotao*)num[i])->apple<<' '; } }