[] 小X的加法难题&&小 X 的密码破译//2018.10.30

题目



解题思路

[problem 1] 简单的模拟
[problem 2] 用桶排暴力算一算


代码(node_1)

#include<cstdio>
#include<iostream>
#include<cstring>
using namespace std;
int a,b; bool c=1; char s; 
int main()
{
	 while (1)
	 {
	 	s=getchar(); 
	 	if (s>='0'&&s<='9'&&c) {
	 		a=(a<<3)+(a<<1)+s-'0';
	 		if (a > 1e8) return !printf("Large");
		 } else 
	 	if (s>='0'&&s<='9'&&!c) {
	 		b=(b<<3)+(b<<1)+s-'0';
	 		if (b > 1e8) return ! printf("Large");
		 } else 
		if (s=='+') c=0; else 
		if (s!=' ') {
			if (a+b<=1e8) printf("%d",a+b); else printf("Large"); 
			return 0; 
		}
	 }
}

代码(node_2)

#include<cstdio>
#define rr register 
#define LL long long
using namespace std; 
const LL ymw=11111111; 
int n,a,b,c,ans,len; bool t[ymw];
int main()
{
	scanf("%d%d%d%d",&n,&a,&b,&c); 
	for (rr LL i=1;i<=n;i++) 
	  t[(int)(((LL)(a*i*i)+(LL)(b*i)+(LL)(c))%ymw)]=1; 	
	for (rr LL i=0;i<ymw;i++)
	  if (t[i]) ans=(int)(((LL)(ans)+(LL)(++len)*i)%ymw); 
	printf("%d",ans); 
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值