ZOJ 3782 G - Ternary Calculation 水
LINK:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3782
题意:给出3个数和两个符号(+-*/%)
思路:拿到题目还以为是要写波兰表达式,仔细一看固定的数和固定的符号,直接if判断好了
/** @Date : 2017-03-23-21.31
* @Author : Lweleth (SoungEarlf@gmail.com)
* @Link : https://github.com/
* @Version :
*/
#include<bits/stdc++.h>
#define LL long long
#define PII pair
#define MP(x, y) make_pair((x),(y))
#define fi first
#define se second
#define PB(x) push_back((x))
#define MMG(x) memset((x), -1,sizeof(x))
#define MMF(x) memset((x),0,sizeof(x))
#define MMI(x) memset((x), INF, sizeof(x))
using namespace std; const int INF = 0x3f3f3f3f;
const int N = 1e5+20;
const double eps = 1e-8; int main()
{
int T;
cin >> T;
while(T--)
{
int a, b, c;
char o1[2], o2[2];
int t = 0, ans = 0;
scanf("%d %s%d %s%d", &a, o1, &b, o2, &c);
//cout << a << o1 << b << o2 << c << endl;
if(o1[0] != '*' && o1[0] != '/' && o1[0] != '%' && o2[0] != '+' && o2[0] != '-')
{
if(o2[0] == '*')
t = b * c;
else if(o2[0] == '/')
t = b / c;
else if(o2[0] == '%')
t = b % c;
if(o1[0] == '+')
t = a + t;
else if(o1[0] == '-')
t = a - t;
}
else
{
if(o1[0] == '+')
t = a + b;
else if(o1[0] == '-')
t = a - b;
else if(o1[0] == '*')
t = a * b;
else if(o1[0] == '/')
t = a / b;
else if(o1[0] == '%')
t = a % b; if(o2[0] == '+')
t = t + c;
else if(o2[0] == '-')
t = t - c;
else if(o2[0] == '*')
t = t * c;
else if(o2[0] == '/')
t = t / c;
else if(o2[0] == '%')
t = t % c;
}
//cout << 5 % 8 % 2 << endl;
printf("%d\n", t);
}
return 0;
}
ZOJ 3782 G - Ternary Calculation 水的更多相关文章
- The 11th Zhejiang Provincial Collegiate Programming Contest->Problem G:G - Ternary Calculation
http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3782 题意:把输入的三元运算用计算机运算出来. ; ci ...
- Ternary Calculation
Ternary Calculation Time Limit : /2000ms (Java/Other) Memory Limit : /65536K (Java/Other) Total Subm ...
- ZOJ 3778 C - Talented Chef 水题
LINK:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3778 题意:有n道菜,每道菜需要\(a_i\)道工序,有m个锅可 ...
- Codeforces Beta Round #10 A. Power Consumption Calculation 水题
A. Power Consumption Calculation 题目连接: http://www.codeforces.com/contest/10/problem/A Description To ...
- 暑假训练Round1——G: Hkhv的水题之二(字符串的最小表示)
Problem 1057: Hkhv的水题之二 Time Limits: 1000 MS Memory Limits: 65536 KB 64-bit interger IO format: ...
- ZOJ 3959 Problem Preparation 【水】
题目链接 http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3959 AC代码 #include <cstdio> ...
- ZOJ 3958 Cooking Competition 【水】
题目链接 http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3958 AC代码 #include <cstdio> ...
- zoj 3827 Information Entropy 【水题】
Information Entropy Time Limit: 2 Seconds Memory Limit: 65536 KB Special Judge Information ...
- ZOJ 1796 Euchre Results 数学水题
http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=1796 题意: 四个人玩游戏,已知三个人的输赢情况,求第四个人的输赢情况. ...
随机推荐
- lintcode-450-K组翻转链表
450-K组翻转链表 给你一个链表以及一个k,将这个链表从头指针开始每k个翻转一下. 链表元素个数不是k的倍数,最后剩余的不用翻转. 样例 给出链表 1->2->3->4->5 ...
- spring-test与junit
1.添加依赖 spring-test junit spring-context(自动添加依赖其他所需的spring依赖包) 2.在class前添加以下注解,用于配置xml文件的位置 @RunWith( ...
- 软工网络15团队作业4——Alpha阶段敏捷冲刺-7
一.当天站立式会议照片: 二.项目进展 昨天已完成的工作: 进一步优化功能与完善服务器. 明天计划完成的工作: 服务器是需要完善,后端的配置还需要修改. 工作中遇到的困难: 今日遇到的困难是服务器后端 ...
- 【beta】阶段会议记录汇总
第一次: http://www.cnblogs.com/yumiaomiao/p/6026752.html 第二次: http://www.cnblogs.com/liquan/p/6031802.h ...
- windows下面安装python3遇到的没有添加到环境变量的问题
windows下面安装python3出现的问题 在官网上面下载最新版的安装包进行安装,并勾选Add Python 3.5 to PATH 安装的过程中可能会出现没有添加到PATH路径的情况 默认的安装 ...
- c语言----程序记录
1.结构体写入文件,读取 #include <stdio.h> #include <string.h> #include <stdlib.h> #define ma ...
- puppeteer设置代理并检查代理是否设置成功
1. 设置代理: 这一步超级简单,但我掉到了坑里并扑腾了小一天的时间,那就是:箭头指向处一定一定不要加空格!!! 2. 检查代理是否设置成功: 在打开的浏览器里,打开百度,输入ip,如果查出来的结果跟 ...
- Java多线程 -yield用法
前几天复习了一下多线程,发现有许多网上讲的都很抽象,所以,自己把网上的一些案例总结了一下! 一. Thread.yield( )方法: 使当前线程从执行状态(运行状态)变为可执行态(就绪状态).cpu ...
- 第154天:canvas基础(一)
一.canvas简介 <canvas> 是 HTML5 新增的,一个可以使用脚本(通常为JavaScript)在其中绘制图像的 HTML 元素.它可以用来制作照片集或者制作简单(也不是 ...
- hihocoder 1828 Saving Tang Monk II (DP+BFS)
题目链接 Problem Description <Journey to the West>(also <Monkey>) is one of the Four Great C ...