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. 匹配html标签的正则式

    $reg = "/<" + element + "[^<>]*?\s+" + attr + "=['\"]?(.*?)[' ...

  2. 怎样安装pip--python的包管理工具

    pip是python的包管理工具,使用它来安装python的模块很方便. pip支持的操作系统:Unix/Linux, OS X, and Windows. 支持的python版本号:2.6, 2.7 ...

  3. asp.net RadioButton控件基础

    RadioButton按钮呢,必须要设置groupname属性的值才能将多个RadioButton按钮设置为单选按钮,当AutoPostBack="true"的时候,在change ...

  4. 网上B2C书城,1.0javaWEB版!!好几天没更新了,都忙着做那个网站了~

    惯例帮师傅打个广告www.java1234.com,从基础学习java WEB! 从最初的构思,到一点点功能的实现,真是不容易啊,由于自己没有项目经验,完全依靠自己的感觉,以及自己琢磨出来的思路来写, ...

  5. Neo4j简介

    Neo4j简介 发表于2013年3月16日 11:52 p.m.    位于分类图数据库与图并行计算 现实中很多数据都是用图来表达的,比如社交网络中人与人的关系.地图数据.或是基因信息等等.RDBMS ...

  6. php mysql_insert_id() 获取为空

    mysql_insert_id() 获取插入数据后的最新的id 遇到问题和解决的步骤如下: 1. 使用后总是返回空的字符串,网上查了一番有人说是id要AUTO_INCREMENT,并且mysql_in ...

  7. leetcode first bad version python

    # The isBadVersion API is already defined for you. # @param version, an integer # @return a bool # d ...

  8. JVM学习之类的卸载机制

    类的生命周期 当Sample类被加载.连接和初始化后,它的生命周期就开始了,当代表Sample类的Class对象不再被引用,即不可触及时,Class对象就会结束生命周期,Sample类在方法区内的数据 ...

  9. javaTemplates-学习笔记四

    应用的调用顺序理解 这个地方很薄弱,浏览器 http://localhost:9000/index.html  ->  conf/routes  ->  app/controllers/A ...

  10. jquery ajax返回json数据进行前后台交互实例

    jquery ajax返回json数据进行前后台交互实例 利用jquery中的ajax提交数据然后由网站后台来根据我们提交的数据返回json格式的数据,下面我来演示一个实例. 先我们看演示代码 代码如 ...