这个题目很简单,不知为什么ACM把它定为难度是2. // Hartals.cpp : Defines the entry point for the console application. // #include "stdafx.h" using namespace std; int _tmain(int argc, _TCHAR* argv[]) { int NumH=0; //Enter the number of the data; int date=0; //Enter the date of hartal; int NumP=0; //Enter the number of party; int InterH[100]={0}; //Enter the interval of hartal; int NumDate[3650]={0}; // How long does the hartal keep; int NumHartal=0; cin>>NumH; // Read the data and handle it; while(NumH!=0) { cin>>date; cin>>NumP; for(int i=0;i<NumP;++i)cin>>InterH[i]; int n=0; for(int j=0;j<NumP;++j) { n=date/InterH[j]; int m=1; while(n!=0) { if(NumDate[InterH[j]*m-1]==0)NumDate[InterH[j]*m-1]=1; --n; ++m; } } for(int x=0;x<date;++x) { if((NumDate[x]==1)&&(x!=5)&&(x!=6)&&((x-5)%7!=0)&&((x-6)%7!=0))++NumHartal; } cout<<NumHartal<<"/n"; NumHartal=0; for(int y=0;y<date;++y)NumDate[y]=0; --NumH; } system("pause"); return 0; }