枚举:

1.完美立方

#include<iostream>

#include <cstdio>

using namespace std;

int main()

{

int N;

scanf("%d",&N);

for (int a = 2; a <= N; ++a)
for(int b = 2;b< a;++b)
for(int c = b;c < a;++c)
for(int d = c;d < a;++d)
if(a * a * a == b *b *b + c*c*c+d*d*d)
printf("Cube = %d,Triple =(%d,%d,%d)\n",a,b,c,d);

return 0;

}

2.

生理周期

原题如下:

Biorhythms
Time Limit: 1000MS   Memory Limit: 10000K
Total Submissions: 110700   Accepted: 34443

Description

Some people believe that there are three cycles in a person's life that start the day he or she is born. These three cycles are the physical, emotional, and intellectual cycles, and they have periods of lengths 23, 28, and 33 days, respectively. There is one peak in each period of a cycle. At the peak of a cycle, a person performs at his or her best in the corresponding field (physical, emotional or mental). For example, if it is the mental curve, thought processes will be sharper and concentration will be easier. 
Since the three cycles have different periods, the peaks of the three cycles generally occur at different times. We would like to determine when a triple peak occurs (the peaks of all three cycles occur in the same day) for any person. For each cycle, you will be given the number of days from the beginning of the current year at which one of its peaks (not necessarily the first) occurs. You will also be given a date expressed as the number of days from the beginning of the current year. You task is to determine the number of days from the given date to the next triple peak. The given date is not counted. For example, if the given date is 10 and the next triple peak occurs on day 12, the answer is 2, not 3. If a triple peak occurs on the given date, you should give the number of days to the next occurrence of a triple peak. 

Input

You will be given a number of cases. The input for each case consists of one line of four integers p, e, i, and d. The values p, e, and i are the number of days from the beginning of the current year at which the physical, emotional, and intellectual cycles peak, respectively. The value d is the given date and may be smaller than any of p, e, or i. All values are non-negative and at most 365, and you may assume that a triple peak will occur within 21252 days of the given date. The end of input is indicated by a line in which p = e = i = d = -1.

Output

For each test case, print the case number followed by a message indicating the number of days to the next triple peak, in the form:

Case 1: the next triple peak occurs in 1234 days.

Use the plural form ``days'' even if the answer is 1.

Sample Input

0 0 0 0
0 0 0 100
5 20 34 325
4 5 6 7
283 102 23 320
203 301 203 40
-1 -1 -1 -1

Sample Output

Case 1: the next triple peak occurs in 21252 days.
Case 2: the next triple peak occurs in 21152 days.
Case 3: the next triple peak occurs in 19575 days.
Case 4: the next triple peak occurs in 16994 days.
Case 5: the next triple peak occurs in 8910 days.
Case 6: the next triple peak occurs in 10789 days.

Source

 
 

#include <iostream>
#include<cstdio>
using namespace std;
#define N 21252;
int main()
{
int p,e,i,k,d,caseNO = 0;
while(cin >>p>> e>>i >>d && p != -1)
{
++caseNO;

for(k = d+1 ;(k-p)%23;++k);
for(;(k-e)%28; k+= 23);
for (;(k-i)%33;k+=23*28);
cout << "caseNO" << ": the next triple peak occurs in " << k-d<<endl;

}

return 0;
}

3.称硬币

#include <iostream>
#include <cstring>
using namespace std;
char Left[3][7];
char Right[3][7];
char result[3][7];
bool isFake(char c,bool light);

int main()
{
int t;
cin >> t;
while(t--)
{
for(int i = 0; i < 3; i++)
cin >> Left[i] >> Right[i] >> result[i];
for(char c = 'A';c <= 'L';c++)
{
if(isFake(c,true))
{
cout << c << "is the counterfeit coin and it is light.\n";
break;
}
else if (isFake(c,false))
{
cout << c << "is the counterfeit coin and it is heavy.\n";
break;

}
}
}

return 0;
}
bool isFake(char c,bool light)
{
for (int i=1;i<=3;i++)
resul
if ()
return true;
else
return false;
}

 

4,熄灯问题

#include<memory>
#include<string>
#include<cstring>
#include <iostream>
using namespace std;
char oriLights[5];
char lights[5];
char result[5];

int GetBit(char c,int i)
{
return (c >> i) & 1;
}

void SetBit(char & c, int i ,int v)//c 的第i位变位v
{
if(v == 1){
c |= ( 1 << i);//c 或 后移i个位置
}
else // v == 0
c &= ~(1 << i); //c的第i位为1 ; 取反(第i位成0);与(第i位成0)
}
void FlipBit(char &c, int i)
{
c ^= ( 1 << i);
}

void OutPutResult(int t,char result[])
{
cout
}

---------------------------------------分隔符-------------------------------------------------------------------

while(~scanf("%d%d",&m,&n))等同于while (scanf("%d%d",&m,&n)!=EOF)

---------------------------------------分隔符-------------------------------------------------------------------

#include <stdio.h>

#define maxsize 32575

typedef int SElemType;

typedef struct stack{

SElemType *base,*top;

int stacksize;

}stack;

int Initstack(stack &S){  &s  S    *S  &S 

S.base = new SElemType[maxsize];

if(!S.base)

return -1;

S.base = S.top;

S.stacksize = maxsize;

return 0;

}

int push(stack &S,SElemType e){

if(S.top -S.base == S.stacksize)

return -1;

*(S.top++) = e;

return e;

}

int pop(stack &S,SElemType &e){

if(S.top == S.base)

return -1;

e = *--S.top;

return 1;

}

int stackEmpty(stack S){

if(S.base == S.top)

return -1;

return 0;

}

//十进制转换为八进制

int main(int a){

stack S;

SElemType e;

Initstack(S);

stackEmpty(S);

scanf("%d",&a);

while(a){

push(S,a%8);

a = a/8;

}

while(!stackEmpty(S)){

pop(S,e);

printf("%d",e);

}

return 0;

}

---------------------------------------分隔符-------------------------------------------------------------------

codes often WA的更多相关文章

  1. UVA-146 ID Codes

    It is 2084 and the year of Big Brother has finally arrived, albeit a century late. In order to exerc ...

  2. CPU状态信息us,sy,ni,id,wa,hi,si,st含义

    转自:http://blog.csdn.net/sasoritattoo/article/details/9318893 转自:http://fishermen.iteye.com/blog/1995 ...

  3. Lattice Codes

    最近在做的一些关于lattice codes的工作,想记录下来. 首先,我认为lattice coding是一种联合编码调制技术,将消息序列映射到星座点.其中一个良好的性质是lattice point ...

  4. System Error Codes

    很明显,以下的文字来自微软MSDN 链接http://msdn.microsoft.com/en-us/library/windows/desktop/ms681382(v=vs.85).aspx M ...

  5. Windows Locale Codes - Sortable list(具体一个语言里还可具体细分,中国是2052,法国是1036)

    Windows Locale Codes - Sortable list NOTE: Code page is an outdated method for character encoding, y ...

  6. Bar codes in NetSuite Saved Searches(transport/reprint)

    THIS IS A COPY FROM BLOG Ways of incorporating Bar Codes into your Netsuite Saved Searches.    Code ...

  7. Secret Codes

    Secret Codes   This is a list of codes that can be entered into the dialer to output the listed info ...

  8. Disabling default console handler in Java Logger by codes

    The open source packages usu. relies on log4j or Java Logger to print logs, by default the console h ...

  9. uva146 ID codes

    Description It is 2084 and the year of Big Brother has finally arrived, albeit a century late. In or ...

随机推荐

  1. [UE4]创建Shooter基类,2种方法

    一.可以通过直接修改"BP_FPPCharacter"的名字为“BP_Shooter”作为基类,然后新建一个"BP_FPPCharacter"继承自“BP_Sh ...

  2. Shiro Realm

    Realm: 在实际应用中,shiro从数据库中获取安全数据(如用户.角色.权限),而不是从ini中,可作为安全数据源 即SecurityManager要验证用户身份,那么它需要从Realm获取相应的 ...

  3. 邮件过滤-LSTM-Spam Filtering

    Github: https://github.com/cjyanyi/Spam_Filtering_LSTM_Enron 模型结构: CNN-LSTM 开发库: Keras word2vec Enro ...

  4. react 数据管理之state思想指南

    react的数据管理库有不少,最常听到的可能是mobx redux altjs之类的,当然还有很多其他,可以自己搜索. 为什么需要数据管理库呢,因为react本身只是为了实现view的表现,而不是数据 ...

  5. Java分布式锁的三种实现方案(redis)

    方案一:数据库乐观锁 乐观锁通常实现基于数据版本(version)的记录机制实现的,比如有一张红包表(t_bonus),有一个字段(left_count)记录礼物的剩余个数,用户每领取一个奖品,对应的 ...

  6. element-ui 带单选框的表格

    效果:不只是带单选框,点击当前行单选框选中状态网上查了一些发现很多都是只能点击当前radio选中当前行,配合element-ui的单选table时发现两个的选择状态是不一致的,所以调整了一下效果 提供 ...

  7. JDK源码阅读顺序

      很多java开发的小伙伴都会阅读jdk源码,然而确不知道应该从哪读起.以下为小编整理的通常所需阅读的源码范围. 标题为包名,后面序号为优先级1-4,优先级递减 1.java.lang 1) Obj ...

  8. android_自定义布局例子

    为什么要写自定义布局: 1.在实现大量重复的子按键或者子布局时,如果一个一个去复写工作量庞大,就需要创建自定义布局直接导入布局里,可以节省大量的时间 创建自定义布局的步骤: 1.编写一个自定义xml布 ...

  9. 【Servlet】监听器入门

  10. python中的swapcase

    swapcase()将字符串中的字母小写变大写.大写变小写,举个例子: 1 a = "hELLO wORLD" 2 a1 = a.swapcase() 3 print(a1) 输出 ...