ACM数学题目1 Multiple of Seven

本文探讨了如何高效解决ACM竞赛中的数学题目,特别是关于判断一个数是否能被7整除的问题。通过运用同余性质,将问题简化为只关注高位数,提出时间复杂度为O(n%6)或O(1)的解决方案。关键在于理解数字的周期性和奇偶位的乘积对模7的影响。
摘要由CSDN通过智能技术生成

声明:

题目来源:HOJ 13375(Origin: HNU Contest)

本题为本人与同学讨论做出,仅给出本人的解法。

 

Multiple of 7

Time Limit: 1000ms, Special Time Limit:2500ms, Memory Limit:65536KB
Total submit users: 127, Accepted users: 62
Problem 13775 :

No special judgement

Problem description

Give you an integer such as abab..... with length n. where a,b are digit.1< = a < = 9, 0< = b < = 9. Your task is to answer whether the given integer is multiple of 7.

For example, 3535 ,343,141414 are multiples of 7,and 121,11,2,232 are not.
 

Input

There are multiple test cases, the first line contain an i
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值