codes often WA
枚举:
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.
生理周期
原题如下:
| Time Limit: 1000MS | Memory Limit: 10000K | |
| Total Submissions: 110700 | Accepted: 34443 |
Description
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
Output
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的更多相关文章
- UVA-146 ID Codes
It is 2084 and the year of Big Brother has finally arrived, albeit a century late. In order to exerc ...
- CPU状态信息us,sy,ni,id,wa,hi,si,st含义
转自:http://blog.csdn.net/sasoritattoo/article/details/9318893 转自:http://fishermen.iteye.com/blog/1995 ...
- Lattice Codes
最近在做的一些关于lattice codes的工作,想记录下来. 首先,我认为lattice coding是一种联合编码调制技术,将消息序列映射到星座点.其中一个良好的性质是lattice point ...
- System Error Codes
很明显,以下的文字来自微软MSDN 链接http://msdn.microsoft.com/en-us/library/windows/desktop/ms681382(v=vs.85).aspx M ...
- Windows Locale Codes - Sortable list(具体一个语言里还可具体细分,中国是2052,法国是1036)
Windows Locale Codes - Sortable list NOTE: Code page is an outdated method for character encoding, y ...
- 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 ...
- Secret Codes
Secret Codes This is a list of codes that can be entered into the dialer to output the listed info ...
- 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 ...
- uva146 ID codes
Description It is 2084 and the year of Big Brother has finally arrived, albeit a century late. In or ...
随机推荐
- [UE4]Overlay容器:图片随着其他容器(比如Vertical Box)大小而同步改变
- 第9课 基于范围的for循环
1. 基于范围的for循环(range-based for) (1)语法:for(decl : coll){//statement} ①decl用于声明元素及类型,如int elem或auto ele ...
- Python工程化小结
对如何写一个工业级的Python项目作一个top-down小结. 一.项目结构 顶层结构: 文件夹: model可以是项目中的自定义类: utils是一些工程工具,比如log,tracker log存 ...
- WebView加载失败或网络异常时,替换WebView的错误界面;
WebView在加载失败时会显示一个失败原因的界面,各个手机显示的界面还都不一样,部分手机还会把Url显示出来:我们要做的就是统一加载失败的界面: 大概思路:在WebView这个控件上面再覆盖一个Vi ...
- 动态参数(*args,**kwargs),命名空间和作用域,global和nonlocal,函数的嵌套
1. 动态参数 位置参数的动态参数: *args 关键字参数的动态参数 : **kwargs 顺序: 位置,*args,默认值,**kwargs 在形参上*聚合, **聚合 在实参上*打散, **打散 ...
- js解析多层嵌套的json,取出所有父元素属性和遍历所有子元素
已知一个多层嵌套的json,取出所有父元素和子元素的id值 思路:因为不知道到底嵌套了多少层,递归有可能造成栈溢出.查询时间特别久的问题 所以先查询一次,判断是否有子节点,如果有,取出子节点并到父节点 ...
- 第一次调用从server获取Cookie
System.setProperty("javax.net.ssl.trustStore", certPath); public String getCookieString(St ...
- Linux网络管理-相关笔记【自用】
ISO/OSI七层模型应用层 APDU 应用层协议数据单元 越靠近用户表示层 PPDU 表示层协议数据单元会话层 SPDU 会话协 ...
- SAP HANA数据库架构部署方法
HANA作为内存数据库,在实现高性能访问的同时,必须也要有稳定的架构,今天我们就来看看企业部署SAP HANA时应该如何来设计数据库的架构. HANA数据库在安装时,有以下几种选择方法,为方便大家理解 ...
- django之urlresolver
>>> from django.utils.regex_helper import normalize >>> bits=normalize(r'^static/( ...