Codeforces Round #268 (Div. 2)
补题解:
E:只会第四种解法;也只看懂了这一种。
PS:F[X+10^18]=F[X]+1;F[X]表示X的数字之和;
假设X,F[10^18+X]+F[10^18+X-1]+......F[10^18+1]=F[1]+.....+F[X]+X;
这个应该没问题所以有G[10^18+X]-G[10^18]=G[X]+X;
G[X]表示:1-X的数字和的总和;
根据G[10^X]=45*X*10^(X-1);所以G[10^18]=45*18*10^17;
所以G[10^18+X]-G[X]=(G[10^18]+X)%a;
然后就可以推出时X的大小,X=a-G[10^18]%a;
这样这题就完美解决;
#include <stdio.h>
#include<iostream>
void solve(){
unsigned long long s = 100000000000000000ll;
__int64 p = s * ;
__int64 a;
scanf("%I64d",&a);
s = (s * ) % a;
s = (s * + ) % a;
a = a - s;
printf("%I64d %I64d\n", + a,p + a);
}
int main(){
solve();
return ;
}
D题:@狗哥有个好想法;
假如B>A;
那么对于一个数组最小的数X,如果能在B-X=PB找到他的匹配,那么不用再A中找到,
原因是假如X“嫁"给了A,在A中会有一个A-X=YA与之搭配。
但是PB就找不到”老婆“了,因为A-X<B-X,但是X已经是最小的,所以PB就无法对应了,
然后就是写法的问题了;
#include<iostream>
#include<stdio.h>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<map>
#include<string>
typedef long long ll;
using namespace std;
int ans[];
map<int,int>mp; int n,a,b;
int pa,pb; int main()
{
cin>>n>>a>>b;
for (int i=;i<=n;i++)
{
int x;
cin>>x;
mp[x]=i;
}
int pa=,pb=;
if (a>b) swap(a,b),swap(pa,pb); for (map<int,int>::iterator mi=mp.begin();mi!=mp.end();mi++)
{
int val=mi->first;
int pos=mi->second;
if (ans[pos]) continue;
if (mp.find(b-val)!=mp.end()&&ans[mp[b-val]]!=pa)
ans[pos]=ans[mp[b-val]]=pb;
else if (mp.find(a-val)!=mp.end()&&ans[mp[a-val]]!=pb)
ans[pos]=ans[mp[a-val]]=pa;
else
{
cout<<"NO"<<endl;
return ;
}
}
cout<<"YES"<<endl;
for (int i=;i<=n;i++) cout<<ans[i]-<<" ";
return ;
}
C:我分奇数偶数;
因为1*2*3*4=24;
6-5=1;
8-7=1;
10-9=1;
发现了什么,
奇数也可以类推;
1,2,3,4,5手动找一下;
7-6=1;
9-8=1;
然后就可以了
B,A基本照着模拟就可以了
Codeforces Round #268 (Div. 2)的更多相关文章
- Codeforces Round #268 (Div. 2) ABCD
CF469 Codeforces Round #268 (Div. 2) http://codeforces.com/contest/469 开学了,时间少,水题就不写题解了,不水的题也不写这么详细了 ...
- Codeforces Round #268 (Div. 1) B. Two Sets 暴力
B. Two Sets Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/468/problem/B ...
- Codeforces Round #268 (Div. 1) A. 24 Game 构造
A. 24 Game Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/468/problem/A D ...
- 贪心+bfs 或者 并查集 Codeforces Round #268 (Div. 2) D
http://codeforces.com/contest/469/problem/D 题目大意: 给你一个长度为n数组,给你两个集合A.B,再给你两个数字a和b.A集合中的每一个数字x都也能在a集合 ...
- Codeforces Round #268 (Div. 2) (被屠记)
c被fst了................ 然后掉到600+.... 然后...估计得绿名了.. sad A.I Wanna Be the Guy 题意:让你判断1-n个数哪个数没有出现.. sb题 ...
- Codeforces Round #268 (Div. 1) 468D Tree(杜教题+树的重心+线段树+set)
题目大意 给出一棵树,边上有权值,要求给出一个1到n的排列p,使得sigma d(i, pi)最大,且p的字典序尽量小. d(u, v)为树上两点u和v的距离 题解:一开始没看出来p需要每个数都不同, ...
- Codeforces Round #268 (Div. 2) D. Two Sets [stl - set + 暴力]
8161957 2014-10-10 06:12:37 njczy2010 D - Two Sets GNU C++ A ...
- Codeforces Round #366 (Div. 2) ABC
Codeforces Round #366 (Div. 2) A I hate that I love that I hate it水题 #I hate that I love that I hate ...
- Codeforces Round #354 (Div. 2) ABCD
Codeforces Round #354 (Div. 2) Problems # Name A Nicholas and Permutation standard input/out ...
随机推荐
- js 将json字符串转换为json兑现
在数据传输过程中,json是以文本,即字符串的形式传递的,而JS操作的是JSON对象,所以,JSON对象和JSON字符串之间的相互转换是关键.例如:JSON字符串:var str1 = '{ &quo ...
- Python核心编程--学习笔记--9--文件和输入输出
本章将深入介绍Python的文件处理和相关输入输出能力,包括:文件对象(以及它的内建函数.内建方法和属性),标准文件,文件系统的访问方法,文件执行,最后简要涉及持久存储和标准库中与文件有关的模块. 1 ...
- wpf程序热键的一个类
using System; using System.Collections.Generic; using System.Linq; using System.Runtime.InteropServi ...
- DB2中的转义字符
1.数据库脚本 )); ,'20%'); ,'OLIVER_QIN'); ,'AA''') 2.以下是DB2的转义字符 2.1 对“%”的转义 SELECT * FROM OLIVER_11 WHER ...
- C# ArrayList的用法总结
C# ArrayList的用法总结 System.Collections.ArrayList类是一个特殊的数组.通过添加和删除元素,就可以动态改变数组的长度. 一.优点 1. 支持自动改变大小的功能 ...
- Unity3d Shortcuts
参考:http://www.ceeger.com/Manual/ 场景视图导航 Click-drag to drag the camera around. 点击拖拽平移场景视图 Hold Alt a ...
- Table ‘performance_schema.session_variables’ doesn’t exist
运行mysql时,提示Table ‘performance_schema.session_variables’ doesn’t exist 解决的方法是: 第一步:在管理员命令中输入: mysql_u ...
- Redis 在windows环境下安装
一.下载适合自己的windows版本 下载地址:https://github.com/dmajkic/redis/downloads 当你解压后,就拥有了全套的应用文件
- JavaScript插入节点
1. document.write("<p>This is inserted.</p>"); 该方法必须加在HTML文档内,违背了结构行为分离原则,不推荐. ...
- 使用itunes同步ios时丢失照片恢复
因没有备份,在使用同步功能后,发现照片被清空了,找到恢复方法,分享之! from:http://modmyi.com/forums/native-iphone-ipod-touch-app-discu ...