题目链接:https://vjudge.net/problem/Gym-102460E

思路:求:

题目当中给了一段伪代码算法,仔细一看发现它是不会记录负数情况,所以与正确答案会有误差,现在题目给定K误差大小和L该数组的长度(注意L要小于2000,不然不符合上面的式子)。那么我门假设a[1]=-1,

构造l=1999,那么假算法的结果为1998*(a[2]+a[3]+...+a[n]),正确答案为1999*(a[2]+a[3]+...+a[n]-1),因为假算法比正确答案小K,那么1998*(a[2]+a[3]+...+a[n])+K=1999*(a[2]+a[3]+...+a[n]-1);那么得到(a[2]+a[3]+...+a[n])=k+1999,只要随便构造一下a[i]就可以了。

  1 #include <bits/stdc++.h>
2 #include <time.h>
3 #include <set>
4 #include <map>
5 #include <stack>
6 #include <cmath>
7 #include <queue>
8 #include <cstdio>
9 #include <string>
10 #include <vector>
11 #include <cstring>
12 #include <utility>
13 #include <cstring>
14 #include <iostream>
15 #include <algorithm>
16 #include <list>
17 using namespace std;
18 //cout<<setprecision(10)<<fixed;
19 #define eps 1e-6
20 #define PI acos(-1.0)
21 #define lowbit(x) ((x)&(-x))
22 #define zero(x) (((x)>0?(x):-(x))<eps)
23 #define mem(s,n) memset(s,n,sizeof s);
24 #define ios {ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);}
25 typedef long long ll;
26 typedef unsigned long long ull;
27 const int maxn=1e6+5;
28 const ll Inf=0x7f7f7f7f7f7f7f;
29 const ll mod=1e6+3;
30 //const int N=3e3+5;
31 bool isPowerOfTwo(int n) { return n > 0 && (n & (n - 1)) == 0; }//判断一个数是不是 2 的正整数次幂
32 int modPowerOfTwo(int x, int mod) { return x & (mod - 1); }//对 2 的非负整数次幂取模
33 int getBit(int a, int b) { return (a >> b) & 1; }// 获取 a 的第 b 位,最低位编号为 0
34 int Max(int a, int b) { return b & ((a - b) >> 31) | a & (~(a - b) >> 31); }// 如果 a>=b,(a-b)>>31 为 0,否则为 -1
35 int Min(int a, int b) { return a & ((a - b) >> 31) | b & (~(a - b) >> 31); }
36 ll gcd(ll a, ll b) {return b ? gcd(b, a % b) : a;}
37 ll lcm(ll a, ll b) {return a / gcd(a, b) * b;}
38 inline int read()
39 {
40 int X=0; bool flag=1; char ch=getchar();
41 while(ch<'0'||ch>'9') {if(ch=='-') flag=0; ch=getchar();}
42 while(ch>='0'&&ch<='9') {X=(X<<1)+(X<<3)+ch-'0'; ch=getchar();}
43 if(flag) return X;
44 return ~(X-1);
45 }
46 inline void write(int X)
47 {
48 if(X<0) {X=~(X-1); putchar('-');}
49 if(X>9) write(X/10);
50 putchar(X%10+'0');
51 }
52 /*
53 inline int write(int X)
54 {
55 if(X<0) {putchar('-'); X=~(X-1);}
56 int s[20],top=0;
57 while(X) {s[++top]=X%10; X/=10;}
58 if(!top) s[++top]=0;
59 while(top) putchar(s[top--]+'0');
60 }
61 */
62 int Abs(int n) {
63 return (n ^ (n >> 31)) - (n >> 31);
64 /* n>>31 取得 n 的符号,若 n 为正数,n>>31 等于 0,若 n 为负数,n>>31 等于 -1
65 若 n 为正数 n^0=n, 数不变,若 n 为负数有 n^(-1)
66 需要计算 n 和 -1 的补码,然后进行异或运算,
67 结果 n 变号并且为 n 的绝对值减 1,再减去 -1 就是绝对值 */
68 }
69 ll binpow(ll a, ll b) {
70 ll res = 1;
71 while (b > 0) {
72 if (b & 1) res = res * a%mod;
73 a = a * a%mod;
74 b >>= 1;
75 }
76 return res%mod;
77 }
78 void extend_gcd(ll a,ll b,ll &x,ll &y)
79 {
80 if(b==0) {
81 x=1,y=0;
82 return;
83 }
84 extend_gcd(b,a%b,x,y);
85 ll tmp=x;
86 x=y;
87 y=tmp-(a/b)*y;
88 }
89 ll mod_inverse(ll a,ll m)
90 {
91 ll x,y;
92 extend_gcd(a,m,x,y);
93 return (m+x%m)%m;
94 }
95 ll eulor(ll x)
96 {
97 ll cnt=x;
98 ll ma=sqrt(x);
99 for(int i=2;i<=ma;i++)
100 {
101 if(x%i==0) cnt=cnt/i*(i-1);
102 while(x%i==0) x/=i;
103 }
104 if(x>1) cnt=cnt/x*(x-1);
105 return cnt;
106 }
107 int t,k,l;
108 int main()
109 {
110 t=read();
111 while(t--)
112 {
113 k=read();
114 l=read();
115 if(l>=2000) {puts("-1");continue;}
116 else
117 {
118 puts("1999");
119 printf("-1 ");
120 int s=k+1999,x=1e6;
121 for(int i=1;i<1999;i++)
122 {
123 if(s>=x)
124 {
125 printf("%d ",x);
126 s-=x;
127 }
128 else
129 {
130 printf("%d ",s);
131 s=0;
132 }
133 }
134 }
135 }
136 return 0;
137 }

The League of Sequence Designers Gym - 102460E的更多相关文章

  1. Codeforces Gym 101775D Mr. Panda and Geometric Sequence(2017-2018 ACM-ICPC Asia East Continent League Final,D题,枚举剪枝)

    题目链接  ECL-Final 2017 Problem D 题意  给定$2*10^{5}$组询问,每个询问求$l$到$r$之间有多少个符合条件的数 如果一个数小于等于$10^{15}$, 并且能被 ...

  2. Codeforces GYM 100114 C. Sequence 打表

    C. Sequence Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/100114 Description ...

  3. codeforce gym/100495/problem/K—Wolf and sheep 两圆求相交面积 与 gym/100495/problem/E—Simple sequence思路简述

    之前几乎没写过什么这种几何的计算题.在众多大佬的博客下终于记起来了当时的公式.嘚赶快补计算几何和概率论的坑了... 这题的要求,在对两圆相交的板子略做修改后,很容易实现.这里直接给出代码.重点的部分有 ...

  4. Solution -「Gym 102956B」Beautiful Sequence Unraveling

    \(\mathcal{Description}\)   Link.   求长度为 \(n\),值域为 \([1,m]\) 的整数序列 \(\lang a_n\rang\) 的个数,满足 \(\not\ ...

  5. ACM: Gym 101047M Removing coins in Kem Kadrãn - 暴力

     Gym 101047M Removing coins in Kem Kadrãn Time Limit:2000MS     Memory Limit:65536KB     64bit IO Fo ...

  6. ACM: Gym 101047B Renzo and the palindromic decoration - 手速题

     Gym 101047B  Renzo and the palindromic decoration Time Limit:2000MS     Memory Limit:65536KB     64 ...

  7. Gym 100463A Crossings 逆序对

    Crossings Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/100463 Description ...

  8. Codeforces Gym 100342J Problem J. Triatrip 求三元环的数量 bitset

    Problem J. Triatrip Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/100342/at ...

  9. Codeforces Gym 100513G G. FacePalm Accounting

    G. FacePalm Accounting Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/100513 ...

随机推荐

  1. Linux 驱动框架---input子系统框架

    前面从具体(Linux 驱动框架---input子系统)的工作过程学习了Linux的input子系统相关的架构知识,但是前面的学习比较实际缺少总结,所以今天就来总结一下输入子系统的架构分层,站到远处来 ...

  2. 网站资源被盗链的:预防方法 VS 网站资源防盗链的:破解技巧

    1 www.cnblogs.com 发布文章使用:只允许注册用户才可以访问! 1 资源被盗链:(简明定义) 下载者不是从你的网站直接下载资源,而是通过其他盗链网站提供的你的下载资源链接进行下载你的服务 ...

  3. PHP 标记官方简明教程; <?php 和 ?> 与 <?php 的使用场景!

    PHP 标记官方简明教程:  <?php 和 ?> 与 <?php  的使用场景! 1 PHP 标记¶ 当解析一个文件时,PHP 会寻找起始和结束标记,也就是 <?php 和  ...

  4. js console.log all in one

    js console.log all in one this & arguments "use strict"; /** * * @author xgqfrms * @li ...

  5. vue v-io 父子组件双向绑定多个数据

    vue-io-directive 可以减少使用emit,组件自带的v-model好像也只能设置一个 安装 npm i vue-io-directive 使用 import Vue from 'vue' ...

  6. Dart 处理json,built_value库

    原文链接 文档 import 'dart:convert'; main() async { // json 转化为 map String jsonStr = ''' [ {"name&quo ...

  7. C++算法代码——字符串p型编码

    题目来自:http://218.5.5.242:9018/JudgeOnline/problem.php?id=1681 题目描述 给定一个完全由数字字符('0','1','2',-,'9')构成的字 ...

  8. TypeError: Object of type 'datetime' is not JSON serializable

    我的描述:我在flask框架中引用orm查数据库并返回数据,出现此类问题,如下图: 解决方案: 1.从表面意思看,就是说datetime时间类型无法被序列化.于是我百度了网上的同事的解答,大多说是时间 ...

  9. 最实用JS 留着学习

    1.A标签删除 function input(){    var b = window.confirm("确认要删除本条信息!");    if(b==true){     ret ...

  10. 总结 接口 final关键字 abstract关键字 static 关键字

    final关键字: * final 修饰的方法能被继承 不能被重写 * final修饰的类不能被继承 * final 修饰的变量(基本类型)不能被修改 * final 修饰的成员变量必须初始化 局部变 ...