摘要:
inline bool read(int &num) //整数输入{ char in; in=getchar(); if(in==EOF) return false; while(in<'0'||in>'9') in=getchar(); num=in-'0'; while(in=getchar(),in>='0'&&in<='9') //处理大于等于两位数情况 { num*=10,num+=in-'0'; } return true;}原文地址 阅读全文
摘要:
A ring is compose of n circles as shown in diagram. Put natural number 1, 2, ..., n into each circle separately, and the sum of numbers in two adjacent circles should be a prime.Note: the number of first circle should always be 1.#include <iostream>int ring[20],vis[20];using namespace std;bool 阅读全文
摘要:
N个人排成一圈,按顺时针从1到N编号。从1开始顺时针数到第m个人,让其出圈,从下一个人开始继续数,数到第m个人,让其出圈,重复上述过程然后从出圈者的后继位置开始数,重复上述过程,直到所有人都出圈。 n输入:N,m (1<=N,m<=30000) n输出:出圈人的编号序列。很简单的。。。#include <iostream>using namespace std;int A[30001]={0};int n,m,count=0,flag=0;//flag to count to the sum of the people outvoid Joseph(){ for(int 阅读全文