[2017.11.25]verlauf
来源:互联网 发布:山东广电网络集团上市 编辑:程序博客网 时间:2024/06/03 21:41
虽然我只过了95分但是还要写个题解,说不定什么时候RP好就A了,O(∩_∩)O哈哈~。
题面
一个神奇的复数
r=−1+7√i2 ,其中 i 是虚数单位i2=−1 。 对于任意整数x 和 y,
我们都可以找到⼀个有限的整数集合 S 使得x+y7√i=∑k∈Srk 换句话说,我们将 x + y √7 i 转换为 r 进制,每位上是 0 或者 1。其中为 1的位置的集合记做 S 。
输入x 和y,从小到大输出集合 S 中的元素,可以证明 S 是唯一的。 集合中不能包含相同元素。
输入格式
一行两个整数表示 x, y。
输出格式
一行一个数组表示集合 S ,从小到大输出。
样例输入
7 1
样例输出
2 3 4 5 6 7
数据范围与提示
对于 100% 的数据,满足
|x|,|y|≤1018 。对于 50% 的数据,满足
y=0 。对于 50% 的数据,满足
|x|,|y|≤102 。以上两部分数据相交 25%。
思路
找规律,打一个
程序如下:
#include<algorithm>#include<cmath>#include<complex>using namespace std;typedef complex<double> cd;#include<stdio.h>#include<stdlib.h>const cd r=cd(-1.0,sqrt(7.0))/2.0;int main(){ cd rk(1,0); for(int i=0;i<=15;i++){ printf("%5d: ",i); printf("(%g + %g sqrt(7))/2\n",rk.real()*2,rk.imag()*2.0/sqrt(7.0)); rk*=r; } return 0;}
运行结果:
0: (2 + 0 sqrt(7))/2 1: (-1 + 1 sqrt(7))/2 2: (-3 + -1 sqrt(7))/2 3: (5 + -1 sqrt(7))/2 4: (1 + 3 sqrt(7))/2 5: (-11 + -1 sqrt(7))/2 6: (9 + -5 sqrt(7))/2 7: (13 + 7 sqrt(7))/2 8: (-31 + 3 sqrt(7))/2 9: (5 + -17 sqrt(7))/2 10: (57 + 11 sqrt(7))/2 11: (-67 + 23 sqrt(7))/2 12: (-47 + -45 sqrt(7))/2 13: (181 + -1 sqrt(7))/2 14: (-87 + 91 sqrt(7))/2 15: (-275 + -89 sqrt(7))/2
惊奇的发现:当
定义命题
首先,
当
那么:
所以:
由此可得
也可以顺便证得另一个结论:
↑这个结论后文中会用到。
假设
再定义一个数列
则有:
该式可以看成是一个关于r的n次多项式,可用秦九韶算法进行处理。
先分析
假设
所以:
又因为:
所以:
即:
矛盾。
所以
分析完
代码
附上95分代码:
#include<stdio.h>#include<stdlib.h>struct complex{ long long real,imag;};typedef struct complex complex;#define DEBUG (0)#define debug if(DEBUG)#define runtime if(!DEBUG)int main(){ runtime{ freopen("verlauf.in","r",stdin); freopen("verlauf.out","w",stdout); } long long x,y; scanf("%lld%lld",&x,&y); x*=2;y*=2; debug{ printf("x=%lld y=%lld\n",x,y); } int i; for(i=0;!(x==0 && y==0);i++){ debug printf("i=%d x=%lld y=%lld\n",i,x,y); if((x+y)%4!=0){//has value runtime printf("%d ",i); debug printf("[%d] ",i); x-=2; } long long nx=(7*y-x)/4; long long ny=(-x-y)/4; x=nx;y=ny; } return 0;}
- [2017.11.25]verlauf
- [2017.11.25]IO流
- 2017.11.25作业
- 2017.11.25B组总结
- 【Java作业】2017.11.25 / 11.26
- 【2017.11.25普及组模拟】Bob
- > 2242. 【2017.11.25普及组模拟】Bob
- 2017.11.25【NOIP提高组】模拟赛B组总结
- (初中OJ)2242. 【2017.11.25普及组模拟】Bob
- 2017.11.01
- 2017.11.1
- 2017.11.2
- 2017.11.02
- 2017.11.3
- 2017.11.3
- 2017.11.4
- 2017.11.5
- 2017.11.03
- 为什么java里面经常作List判断的时候,既要判断list不为null,又要判断size>0呢?
- cdh上使用spark-thriftserver操作carbondata
- 实现一个函数,打印乘法口诀表,口诀表的行数和列数自己指定。
- dhcp服务器的配置
- ExtJs的列模式column详解
- [2017.11.25]verlauf
- TensorFlow学习笔记-ExponentialMovingAverage
- IAP实现之一内建模式 — cocos2dx
- sublime配置PHP环境
- caffe安装配置
- 深入浅出Zookeeper(一) Zookeeper架构及FastLeaderElection机制
- Play2 for Java(一:简介)
- 蓝桥杯-算法训练 出现次数最多的整数
- linux中数据库的操作命令