USACO section 1.1 C++题解

USACO section1.1:
DONE 2017.03.03 TEXT Submitting Solutions
DONE 2017.03.04 PROB Your Ride Is Here [ANALYSIS]
DONE 2017.03.04 TEXT Contest Problem Types
DONE 2017.03.04 TEXT Ad Hoc Problems
DONE 2017.03.04 PROB Greedy Gift Givers [ANALYSIS]
DONE 2017.03.04 PROB Friday the Thirteenth [ANALYSIS]
DONE 2017.03.04 PROB Broken Necklace [ANALYSIS]

由上可见section1.1中共有四道题,没有考察算法,只是单纯看思考是否到位以及细心程度。


Prob1:Your Ride Is Here(水题)

题意:input给出两个全部由大写字母组成的单词, 每个字母对应一个数字(A-1,B-2……),
两个单词中的字母分别相乘,得到两个数字, 判断这两个数字%47的余数是否相等。

NOTE:由于数据很小,无须担心溢出,但是保险起见,还是在每次运算的过程中取余。(a%b)*(c%b) = (a*c)%b;


源代码:

/*
ID:kongse_1
PROG:ride
LANG:C++ 
*/

#include 
    
    
     
     
#include 
     
     
      
      
#include 
      
      
       
       
using namespace std;

const int MOD = 47;

string a, b;
int num1=1 ,num2=1;

int main()
{	
	freopen("ride.in", "r", stdin);
	freopen("ride.out", "w", stdout);

	cin >> a >> b;
	
	for(int i = 0; i != a.size(); ++i)
		num1 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值