UVA-11111-Generalized Matrioshkas
来源:互联网 发布:node安装anywhere 编辑:程序博客网 时间:2024/05/23 21:56
#include <stdio.h>static int G_END = 0;static int G_CASE_END = 0;static int start = 0;int getNext(){int tmp;char rear = -1;G_END = scanf("%d%c",&tmp,&rear);G_CASE_END = ((rear=='\n'||rear==-1)?1:0);return tmp;}int matrioshka(int size){int free_space = -size;int next;while (1){if(G_CASE_END)break;next = getNext();start = 1;if (next == -size)break;else if (next > 0)return 0;else{int result = matrioshka(next);if(result)free_space -= result;elsefree_space = 0;}}if(free_space > 0 && start){start = 0;return -size;}return 0;}void output(int result){puts(result?":-) Matrioshka!":":-( Try again.");}int main(){char trash[100000];while (1){int most_outer_size = getNext();if(G_END == -1)break;output(matrioshka(most_outer_size));if(!G_CASE_END)gets(trash);}return 0;}
- uva 11111 - Generalized Matrioshkas
- UVa 11111 Generalized Matrioshkas
- uva 11111 - Generalized Matrioshkas
- uva 11111 - Generalized Matrioshkas
- UVa 11111 - Generalized Matrioshkas
- uva 11111 - Generalized Matrioshkas
- UVa 11111 - Generalized Matrioshkas
- UVA-11111-Generalized Matrioshkas
- uva 11111 - Generalized Matrioshkas
- uva-11111 Generalized Matrioshkas
- UVa 11111 - Generalized Matrioshkas
- UVA 11111 Generalized Matrioshkas
- uva 11111 Generalized Matrioshkas
- Generalized Matrioshkas UVA 11111
- UVa:11111 Generalized Matrioshkas
- UVa 11111 Generalized Matrioshkas
- UVA 11111 - Generalized Matrioshkas
- uva 11111 - Generalized Matrioshkas
- Tomcat配置虚拟目录映射
- Oracle产生随机数
- 学习面向对象思想
- STK中的3D模型
- SSH中事务配置详解
- UVA-11111-Generalized Matrioshkas
- 学习驱动编程第一课 VC6.0+3790ddk+vc 助手
- XUL
- python的执行过程
- Java高新技术
- 各种指针的定义
- MyEclipse编码设置及设置单个项目的编码
- linux misc device 混杂设备
- utilities-p571(ASMCMD)--每日一译【2013-1-26】