Problem G: If We Were a Child Again
Problem G: If We Were a Child Again
Time Limit: 1 Sec Memory Limit: 128 MB
Submit: 18 Solved: 14
[Submit][Status][Web Board]
Description
The Problem
The first project for the poor student was to make a calculator that can just perform the basic arithmetic operations.
But like many other university students he doesn’t like to do any project by himself. He just wants to collect programs from here and there. As you are a friend of him, he asks you to write the program. But, you are also intelligent enough to tackle this kind of people. You agreed to write only the (integer) division and mod (% in C/C++) operations for him.
Input
Input is a sequence of lines. Each line will contain an input number. One or more spaces. A sign (division or mod). Again spaces. And another input number. Both the input numbers are non-negative integer. The first one may be arbitrarily long. The second number n will be in the range (0 < n < 231).
Output
A line for each input, each containing an integer. See the sample input and output. Output should not contain any extra space.
Sample Input
110 / 100
99 % 10
2147483647 / 2147483647
2147483646 % 2147483647
Sample Output
1
9
1
2147483646
my answer:
#include<iostream>
#include<cstring>
#include<string>
using namespace std;
int main()
{
char a[];
int t[];
int sum,b,i;
char c;
while(cin>>a)
{
cin>>c;
cin>>b;
int t1=strlen(a);
sum=a[]-''; for( i=;i!=t1;i++){
t[i]=sum/b;
sum=sum%b;
if(sum<b&&i<t1-){
sum=(sum*+a[i+]-''); }
}
if(c=='%')
cout<<sum<<endl;
else{
int start=;
while(!t[start])start++;
if(start==i)cout<<<<endl;
else {
for(int j=start;j<i;j++)
cout<<t[j];
cout<<endl;
}
}
}
return ;
}
Problem G: If We Were a Child Again的更多相关文章
- 实验9:Problem G: 克隆人来了!
想要输出""的话: cout<<"A person whose name is \""<<name<<" ...
- 实验12:Problem G: 强悍的矩阵运算来了
这个题目主要是乘法运算符的重载,卡了我好久,矩阵的乘法用3个嵌套的for循环进行,要分清楚矩阵的乘法结果是第一个矩阵的行,第二个矩阵的列所组成的矩阵. 重载+,*运算符时,可以在参数列表中传两个矩阵引 ...
- 烟大 Contest1024 - 《挑战编程》第一章:入门 Problem G: Check The Check(模拟国际象棋)
Problem G: Check The Check Time Limit: 1 Sec Memory Limit: 64 MBSubmit: 10 Solved: 3[Submit][Statu ...
- The Ninth Hunan Collegiate Programming Contest (2013) Problem G
Problem G Good Teacher I want to be a good teacher, so at least I need to remember all the student n ...
- 【贪心+中位数】【新生赛3 1007题】 Problem G (K)
Problem G Time Limit : 4000/2000ms (Java/Other) Memory Limit : 32768/32768K (Java/Other) Total Sub ...
- Problem G: Keywords Search
Problem G: Keywords SearchTime Limit: 1 Sec Memory Limit: 128 MBSubmit: 10 Solved: 6[Submit][Status] ...
- BZOJ4977 八月月赛 Problem G 跳伞求生 set 贪心
欢迎访问~原文出处——博客园-zhouzhendong 去博客园看该题解 题目传送门 - BZOJ4977 - 八月月赛 Problem G 题意 小明组建了一支由n名玩家组成的战队,编号依次为1到n ...
- Western Subregional of NEERC, Minsk, Wednesday, November 4, 2015 Problem G. k-palindrome dp
Problem G. k-palindrome 题目连接: http://opentrains.snarknews.info/~ejudge/team.cgi?SID=c75360ed7f2c7022 ...
- ZOJ 4010 Neighboring Characters(ZOJ Monthly, March 2018 Problem G,字符串匹配)
题目链接 ZOJ Monthly, March 2018 Problem G 题意 给定一个字符串.现在求一个下标范围$[0, n - 1]$的$01$序列$f$.$f[x] = 1$表示存在一种 ...
随机推荐
- 使用SuperWebSocket 构建实时 Web 应用
Web 应用的信息交互过程通常是客户端通过浏览器发出一个请求,服务器端接收和审核完请求后进行处理并返回结果给客户端,然后客户端浏览器将信息呈现出来,这种机制对于信息变化不是特别频繁的应用尚能相安无事, ...
- 12个CSS高级技巧汇总
1.使用 :not() 在菜单上应用/取消应用边框 先给每一个菜单项添加边框 CSS Code复制内容到剪贴板 /* add border */ .nav li { border-right: 1px ...
- 查看MDB格式文件数据表
当打开一个MDB格式的ACCESS文件后,如果里面默认的都是窗体视图,要查看数据表的信息,可以“创建-查询设计”查看表信息,或是在SQL视图中编写SQL语句来实现. 或按着Shift键打开文件.
- C++关键字(1)——const
1. const修饰普通变量和指针 const修饰变量,一般有两种写法: const TYPE value; TYPE const value; 这两种写法在本质上是一样的.它的含义是:const修饰 ...
- (转)详解汇编系统调用过程(以printf为例)
本文以printf为例,详细解析一个简单的printf调用里头,系统究竟做了什么,各寄存器究竟如何变化. 环境: linux + gnu as assembler + ld linker 如何在汇编调 ...
- 再看static数据成员
当将类的某个数据成员声明为static时,该静态数据成员只能被定义一次,而且要被同类的所有对象共享.各个对象都拥有类中每一个普通数据成员的副本,但静态数据成员只有一个实例存在,与定义了多少类对象无关. ...
- [转载]PDO防注入原理分析以及使用PDO的注意事项
本文全部内容转载自月影无痕的博客http://zhangxugg-163-com.iteye.com/blog/1835721#bc2346092,感谢作者的分享 合理正确使用PDO,可以基本上防止S ...
- SUBSTRING_INDEX ——网上的解释
SUBSTRING_INDEX(str,delim,count) Returns the substring from string str before count occurrences o ...
- Android DatePicker和TimePicker
监测日期改变的监听器: OnDateChangedListener和OnTimeChangedListener() 当用户改变Datepicker里的年.月.日时,将触发 ...
- SQL复杂查询(子查询)
USE STUDY SELECT * from EMP SELECT * FROM SALGRADE --1.查询雇员姓名,所在部门编号和名称 SELECT ename,EMP.deptno,DEPT ...