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的更多相关文章

  1. 实验9:Problem G: 克隆人来了!

    想要输出""的话: cout<<"A person whose name is \""<<name<<" ...

  2. 实验12:Problem G: 强悍的矩阵运算来了

    这个题目主要是乘法运算符的重载,卡了我好久,矩阵的乘法用3个嵌套的for循环进行,要分清楚矩阵的乘法结果是第一个矩阵的行,第二个矩阵的列所组成的矩阵. 重载+,*运算符时,可以在参数列表中传两个矩阵引 ...

  3. 烟大 Contest1024 - 《挑战编程》第一章:入门 Problem G: Check The Check(模拟国际象棋)

    Problem G: Check The Check Time Limit: 1 Sec  Memory Limit: 64 MBSubmit: 10  Solved: 3[Submit][Statu ...

  4. 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 ...

  5. 【贪心+中位数】【新生赛3 1007题】 Problem G (K)

    Problem G Time Limit : 4000/2000ms (Java/Other)   Memory Limit : 32768/32768K (Java/Other) Total Sub ...

  6. Problem G: Keywords Search

    Problem G: Keywords SearchTime Limit: 1 Sec Memory Limit: 128 MBSubmit: 10 Solved: 6[Submit][Status] ...

  7. BZOJ4977 八月月赛 Problem G 跳伞求生 set 贪心

    欢迎访问~原文出处——博客园-zhouzhendong 去博客园看该题解 题目传送门 - BZOJ4977 - 八月月赛 Problem G 题意 小明组建了一支由n名玩家组成的战队,编号依次为1到n ...

  8. 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 ...

  9. ZOJ 4010 Neighboring Characters(ZOJ Monthly, March 2018 Problem G,字符串匹配)

    题目链接  ZOJ Monthly, March 2018 Problem G 题意  给定一个字符串.现在求一个下标范围$[0, n - 1]$的$01$序列$f$.$f[x] = 1$表示存在一种 ...

随机推荐

  1. find the safest road

    find the safest road Time Limit : 10000/5000ms (Java/Other)   Memory Limit : 32768/32768K (Java/Othe ...

  2. 佩特来项目经验小集合(2)___组合查询存储过程,报错 &quot;varchar JBID=&#39;&#39; 转换成数据类型 int 时失败&quot;

       今天写一个组合查询的存储过程遇到这样一个问题:在将 varchar 值 'SELECT * FROM View_DLS_WXJD_Customer WHERE 1=1 and JBID ='' ...

  3. Android SQLite Database Tutorial

    表名: 列(字段): 联系人实体类:构造方法,setters .getters方法 File:   Contact.java package com.example.sqlitetest; publi ...

  4. [mysqldumpslow 报错] Died at /usr/local/mysql/bin/mysqldumpslow line 161, &lt;&gt; chunk 236.

    mysqldumpslow报错:Died at /usr/local/mysql/bin/mysqldumpslow line 161, <> chunk 236. 总结:是由于top数目 ...

  5. Cocos2D-X2.2.3学习笔记8(处理精灵单击、双击和三连击事件)

    我们依据上一次介绍的触屏事件和事件队列等知识来实现触屏的单击,双击,三连击事件. 下图为我们实现的效果图: 单击精灵跳跃一个高度, 双击精灵跳跃的高度比单击的高 三连击精灵跳跃的跟高 好了,開始动手吧 ...

  6. Attempt to call getDuration without a valid mediaplayer

    最近在做一个播放器的小例子,中途遇到 了这个错: Attempt to call getDuration without a valid mediaplayer 解决参考方案如下: 一是如果media ...

  7. cocos2d-x for wp8 设置横竖屏

    在主project文件(xxx.cpp , xxx为你的项目名)中, 函数名为void xxx::SetWindow(CoreWindow^ window) 相关代码片例如以下: <pre na ...

  8. SQL整理4

    --====================简单增删改===========--查看学生表的全部数据select * from studio   --插入一个新的学生信息insert into stu ...

  9. 自学XSL的几个例子

    XSL 指扩展样式表语言(EXtensible Stylesheet Language).XSL用来描述XML文件的格式,类似于我们可以用CSS描述HTML的格式.具体用法请转:http://www. ...

  10. DooDigestAuth php(后台)授权管理类 web浏览器授权

    <?php /** * DooDigestAuth class file. * * @author Leng Sheng Hong <darkredz@gmail.com> * @l ...