跳到正文

题解

题解:UVA621 Secret Research

Distorted_Fate_约 2 分钟
原文
文章信息与版本

文章信息

发布
2024年9月7日
收录
2025年12月12日
更新
2026年11月14日
篇幅
约 2 分钟
获赞
1
题目
UVA621

版本

  1. v1当前

题解:UVA621 Secret Research

有可能是我最后一篇题解了,怀着悲观的态度先提前和 OI 告个别吧。

这题依旧是非常简单,把输入的 SS 根据题目条件判断就行了。先把所有信息列出来,如下。

  • 如果 SS 等于一,四或七十八时,输出加号。
  • SS 结尾的两个数是三和五,输出减号。
  • 当 SS 的最高位是九,最低位是四,输出乘号。
  • 以上三个条件都不符合并且 SS 以一九零开头,输出问号。

多测,细节较少,还是比较简单的,象征性的放个代码吧。

C++
#include<bits/stdc++.h>
using namespace std;
int t;
signed main(){
	//freopen('a.in','r',stdin);
	//freopen('a.out','w',stdout);
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cin>>t;
	while(t--){
		string s;//用字符串好判断
		cin>>s;
		int n=s.size();
		if(s=="1"||s=="4"||s=="78"){
			cout<<'+'<<endl;
			continue;
		}
		if(s[n-1]=='5'&&s[n-2]=='3'){
			cout<<'-'<<endl;
			continue;
		}
		if(s[0]=='9'&&s[n-1]=='4'){
			cout<<'*'<<endl;
			continue;
		}
		if(s[0]=='1'&&s[1]=='9'&&s[2]=='0'){
			cout<<'?'<<endl;
			continue;//不用判断是否符合前面的条件,因为已经continue掉了。
		}
	}
	return 0;
}
原文
存档评论1 条抓取于