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

Re:代妈。。。竟然搞了一次OLE

Posted by 18773005410 at 2016-08-05 10:15:24 on Problem 1207
In Reply To:代妈。。。竟然搞了一次OLE Posted by:KatrineYang at 2016-07-23 08:39:45
> 如果scanf后面不加上>0就会OLE
> 
> #include <iostream>
> #include <stdio.h>
> using namespace std;
> 
> int state[10001] = {0};
> 
> int js(int N){
> 	int n = N;
> 	if(state[n] > 0) return state[n];
> 	int cnt = 0;
> 	while(1){
> 		if(n%2 == 0) n /= 2;
> 		else n = 3*n+1;
> 		cnt++;
> 		if(n <= 10000 && state[n] > 0) {
> 			state[N] = cnt+state[n];
> 			return cnt+state[n];
> 		}
> 	}
> }
> 
> int main() {
> 
> 	int s, e;
> 	state[1] = 1;
> 	while(scanf("%d%d", &s, &e) > 0){
> 		int start, end;
> 		if(s == 0 && e == 0) return 0;
> 		if(s <= e) {
> 			start = s;
> 			end = e;
> 		}
> 		else{
> 			start = e;
> 			end = s;
> 		}
> 		int mx = 0;
> 		for(int i = start; i <= end; i++){
> 			int ans = js(i);
> 			if(mx < ans) mx = ans;
> 		}
> 		printf("%d %d %d\n", s, e, mx);
> 	}
> 	return 0;
> }

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator