Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
Register

## Re:两个版本C优于C++；C只需0M秒AC，6行代码搞定（算法高手）

Posted by ravenclaw at 2020-02-10 16:07:45 on Problem 1017
In Reply To:两个版本C优于C++；C只需0M秒AC，6行代码搞定（算法高手） Posted by:Spider1314 at 2020-02-09 23:47:35
```> C++版：
> #include <iostream>
> using namespace std;
> int main(){
> 	int a,s,d,f,g,r;
> 	while(1){
> 		cin>>a>>s>>d>>f>>g>>r;
> 		if(a+s+d+f+g+r==0) break;
> 		r+=g+f+(d+3)/4;
> 		a-=11*g;
> 		s-=5*f;
> 		if(g=d%4){
> 			s-=7-2*g;
> 			a-=8-g;
> 		}
> 		if(s>0){
> 			r+=(s+8)/9;
> 			a-=4*(9-(s%9));
> 		} else a+=4*s;
> 		if(a>0) r+=(a+35)/36;
> 		cout<<r<<endl;
> 	}
> }
> C版：
> #include<stdio.h>
> int main()
> {
>     int a,b,c,d,e,f,g,h;
>     for(;scanf("%d%d%d%d%d%d",&a,&b,&c,&d,&e,&f),a+b+c+(g=d+e+f);b>(h=5*d+(7-c%4*2)%7)?g+=(b-h+8)/9:0,a>(h=36*(g-f)-25*e-16*d-9*c-4*b)?g+=(a-h+35)/36:0,printf("%d\n",g))g+=c+3>>2;
> }

```

Followed by: