http://www.luogu.org/contest/show?tid=23

表示被普及的虐瞎了T_T_T_T_T_T_T_TT_T_T_T_T_T_T_T_T

33名100多分滚粗

各种贪心神题,各种神题。。

t1:口算练习题

手残判断位时少判了了0.。。80分滚粗

#include <cstdio>
#include <cstring>
#include <cmath>
#include <string>
#include <iostream>
#include <algorithm>
#include <queue>
using namespace std;
#define rep(i, n) for(int i=0; i<(n); ++i)
#define for1(i,a,n) for(int i=(a);i<=(n);++i)
#define for2(i,a,n) for(int i=(a);i<(n);++i)
#define for3(i,a,n) for(int i=(a);i>=(n);--i)
#define for4(i,a,n) for(int i=(a);i>(n);--i)
#define CC(i,a) memset(i,a,sizeof(i))
#define read(a) a=getint()
#define print(a) printf("%d", a)
#define dbg(x) cout << #x << " = " << x << endl
#define printarr(a, n, m) rep(aaa, n) { rep(bbb, m) cout << a[aaa][bbb]; cout << endl; }
inline const int getint() { int r=0, k=1; char c=getchar(); for(; c<'0'||c>'9'; c=getchar()) if(c=='-') k=-1; for(; c>='0'&&c<='9'; c=getchar()) r=r*10+c-'0'; return k*r; }
inline const int max(const int &a, const int &b) { return a>b?a:b; }
inline const int min(const int &a, const int &b) { return a<b?a:b; } int n, h;
int conv(char s[]) {
int r=0, len=strlen(s);
for(int i=0; i<len; ++i) r=r*10+s[i]-'0';
return r;
}
int getc(int a) {
int ret=0;
if(a<=0) ret=1;
a=abs(a);
while(a) ++ret, a/=10;
return ret;
}
void cal(int a, int b) {
int la=getc(a), lb=getc(b), c, lc;
if(h==1) c=a+b, printf("%d+%d=%d\n", a, b, c);
else if(h==2) c=a-b, printf("%d-%d=%d\n", a, b, c);
else c=a*b, printf("%d*%d=%d\n", a, b, c);
lc=getc(c);
printf("%d\n", la+lb+lc+2);
}
int main() {
read(n);
char s[1000];
for1(i, 1, n) {
scanf("%s", s);
if(s[0]>='a'&&s[0]<='c') {
h=s[0]-'a'+1;
int a=getint(), b=getint();
cal(a, b);
}
else {
int a=conv(s), b=getint();
cal(a, b);
}
}
return 0;
}

t2:果汁店的难题

贪心没贪对,20分滚粗。。

贪心:机子没满时就加空的,满了的话从当前人向后找机子的种类,换掉最远的。

这个太不显然。。。

然后听zyf神犇说网络流可做。。。。。。。。。。。。。orzzzzzzzzzzz

完全没看出来啊啊。。。。。。。。。。。。。。。。。

听说是原题:1927: [Sdoi2010]星际竞速

#include <cstdio>
#include <cstring>
#include <cmath>
#include <string>
#include <iostream>
#include <algorithm>
#include <queue>
using namespace std;
#define rep(i, n) for(int i=0; i<(n); ++i)
#define for1(i,a,n) for(int i=(a);i<=(n);++i)
#define for2(i,a,n) for(int i=(a);i<(n);++i)
#define for3(i,a,n) for(int i=(a);i>=(n);--i)
#define for4(i,a,n) for(int i=(a);i>(n);--i)
#define CC(i,a) memset(i,a,sizeof(i))
#define read(a) a=getint()
#define print(a) printf("%d", a)
#define dbg(x) cout << #x << " = " << x << endl
#define printarr(a, n, m) rep(aaa, n) { rep(bbb, m) cout << a[aaa][bbb]; cout << endl; }
inline const int getint() { int r=0, k=1; char c=getchar(); for(; c<'0'||c>'9'; c=getchar()) if(c=='-') k=-1; for(; c>='0'&&c<='9'; c=getchar()) r=r*10+c-'0'; return k*r; }
inline const int max(const int &a, const int &b) { return a>b?a:b; }
inline const int min(const int &a, const int &b) { return a<b?a:b; } const int N=105, K=15;
int a[N], vis[K], pos[N], n, now=1, k, ans=0, d[N][N];
void dp() {
for1(i, 1, n) d[n+1][i]=~0u>>1;
for3(i, n, 1) {
memcpy(d[i], d[i+1], sizeof(d[i]));
d[i][a[i]]=i;
}
}
int main() {
read(k); read(n);
for1(i, 1, n) read(a[i]);
dp();
for1(i, 1, n) {
if(pos[a[i]]) continue;
if(now>k) {
int p=-1, num=0;
for1(j, 1, k) if(d[i][vis[j]]>num) {
p=j; num=d[i][vis[j]];
}
int t=vis[p];
pos[t]=0;
vis[p]=a[i];
pos[a[i]]=p;
++ans;
}
else pos[a[i]]=now, vis[now++]=a[i];
}
print(ans);
return 0;
}

t3:排序

官方题解在说什么完全不会

置换群今天才学会。。。。。

T_T

#include <cstdio>
#include <cstring>
#include <cmath>
#include <string>
#include <iostream>
#include <algorithm>
#include <queue>
using namespace std;
#define rep(i, n) for(int i=0; i<(n); ++i)
#define for1(i,a,n) for(int i=(a);i<=(n);++i)
#define for2(i,a,n) for(int i=(a);i<(n);++i)
#define for3(i,a,n) for(int i=(a);i>=(n);--i)
#define for4(i,a,n) for(int i=(a);i>(n);--i)
#define CC(i,a) memset(i,a,sizeof(i))
#define read(a) a=getint()
#define print(a) printf("%d", a)
#define dbg(x) cout << #x << " = " << x << endl
typedef long long ll;
#define printarr(a, n, m) rep(aaa, n) { rep(bbb, m) cout << a[aaa][bbb]; cout << endl; }
inline const ll getint() { ll r=0, k=1; char c=getchar(); for(; c<'0'||c>'9'; c=getchar()) if(c=='-') k=-1; for(; c>='0'&&c<='9'; c=getchar()) r=r*10+c-'0'; return k*r; }
inline const int max(const int &a, const int &b) { return a>b?a:b; }
inline const ll min(const ll &a, const ll &b) { return a<b?a:b; } const int N=200010;
ll ans, x[N], y[N], mn=~0ull>>1;
int b[N], pos[N], n;
bool vis[N];
const bool cmp(const int &a, const int &b) { return x[a]<x[b]; }
int main() {
read(n);
for1(i, 1, n) read(x[i]);
for1(i, 1, n) read(y[i]), mn=min(mn, y[i]);
for1(i, 1, n) b[i]=i;
sort(b+1, b+1+n, cmp);
for1(i, 1, n) pos[b[i]]=i;
for1(i, 1, n) if(!vis[i]) {
int j=i;
ll sum=0, mini=~0ull>>1, len=0;
while(!vis[j]) {
sum+=y[j];
mini=min(mini, y[j]);
vis[j]=1;
++len;
j=pos[j];
}
ans+=sum+min((len-2)*mini, (len+1)*mn+mini);
}
printf("%lld", ans);
return 0;
}

t4:数字游戏

博弈论写渣了。。。。。。。。。。没想到博弈论里边也有贪心。。

之前以为质数必胜,然后博弈论爆搜一下。。。

然后45分滚粗。。。

贪心:将数分解质因数。。。然后找2个最小的做乘积然后就必胜。。。

#include <cstdio>
#include <cstring>
#include <cmath>
#include <string>
#include <iostream>
#include <algorithm>
#include <queue>
using namespace std;
#define rep(i, n) for(int i=0; i<(n); ++i)
#define for1(i,a,n) for(int i=(a);i<=(n);++i)
#define for2(i,a,n) for(int i=(a);i<(n);++i)
#define for3(i,a,n) for(int i=(a);i>=(n);--i)
#define for4(i,a,n) for(int i=(a);i>(n);--i)
#define CC(i,a) memset(i,a,sizeof(i))
#define read(a) a=getint()
#define print(a) printf("%d", a)
#define dbg(x) cout << #x << " = " << x << endl
#define printarr(a, n, m) rep(aaa, n) { rep(bbb, m) cout << a[aaa][bbb]; cout << endl; }
inline const long long getint() { long long r=0, k=1; char c=getchar(); for(; c<'0'||c>'9'; c=getchar()) if(c=='-') k=-1; for(; c>='0'&&c<='9'; c=getchar()) r=r*10+c-'0'; return k*r; }
inline const int max(const int &a, const int &b) { return a>b?a:b; }
inline const int min(const int &a, const int &b) { return a<b?a:b; } const int Pcnt=3300000;
long long f[Pcnt], cnt;
int main() {
long long n;
read(n); long long t=n;
for(long long i=2; i*i<=n; ++i)
for(; n%i==0; n/=i)
f[++cnt]=i;
if(t!=n&&n!=1) f[++cnt]=n;
if(cnt!=2) {
puts("1");
printf("%lld\n", f[1]*f[2]);
}
else puts("2");
return 0;
}

CONTEST23 2014xmoi邀请赛(被pj虐哭)的更多相关文章

  1. AI单挑Dota 2世界冠军:被电脑虐哭……

    OpenAI的机器人刚刚在 Dota2 1v1 比赛中战胜了人类顶级职业玩家 Denti.以建设安全的通用人工智能为己任的 OpenAI,通过“Self-Play”的方式,从零开始训练出了这个机器人. ...

  2. 三面阿里,被Java面试官虐哭!现场还原真实的“被虐”场景

    前言 人人都有大厂梦,我也不例外,从大三开始,就一直想进入阿里工作,大毕竟是大厂,想想也没那么容易,不过好在自己学历还过得去,项目经验也有得讲,所以今年也斗胆尝试了一下,直接就投了阿里云计算.简历是过 ...

  3. A Simple Problem with Integers_树状数组

    Problem Description Let A1, A2, ... , AN be N elements. You need to deal with two kinds of operation ...

  4. 用python做些有意思的事——分析QQ聊天记录

    ####################################### 已更新续集,戳这里. ######################################## 是这样的,有位学 ...

  5. BZOJ1116: [POI2008]CLO

    1116: [POI2008]CLO Time Limit: 10 Sec  Memory Limit: 162 MBSubmit: 565  Solved: 303[Submit][Status] ...

  6. V先生:信息流广告标题党必备的500个热词

    稍微没有全都偏,简直仅仅只永远, 已经曾经就竟然,将要立刻刚偶然, 渐渐终于决忽然,难道连续又再三, 也许必须很非常,最太十分更马上, 越极总挺常常再,屡次一定也不还. 你一定不知道.如何.最.咋.是 ...

  7. Codeforces Round #517 Div. 2/Div. 1

    \(n\)天没更博了,因为被膜你赛的毒瘤题虐哭了... 既然打了这次CF还是纪念一下. 看看NOIP之前,接下来几场的时间都不好.这应该是最后一场CF了,差\(4\)分上紫也是一个遗憾吧. A 给一个 ...

  8. 洛谷P4891 序列(势能线段树)

    洛谷题目传送门 闲话 考场上一眼看出这是个毒瘤线段树准备杠题,发现实在太难调了,被各路神犇虐哭qwq 考后看到各种优雅的暴力AC......宝宝心里苦qwq 思路分析 题面里面是一堆乱七八糟的限制和性 ...

  9. WC2019 20天训练

    Day -1 2019.1.2 初步计划: 0x60 图论 std 洛谷提高剩余练习 NOIP2018遗留题解 洛谷省选基础练习 数学: 1.数论 2.组合数学(练习:莫比乌斯反演) 3.概率(练习: ...

随机推荐

  1. 模式的秘密-代理模式(2)-JDK动态代理

    代理模式-动态代理 (1) (2) 代码实践动态代理: 第一步:被代理类的接口: package com.JdkProxy; public interface Moveable { void move ...

  2. django 实现linux运维管理平台

    概述 使用django实现一个linux运维管理平台,可以实现注册登录,机器管理 ,服务器批量操作,服务器性能监控. 详细 代码下载:http://www.demodashi.com/demo/112 ...

  3. 微信公共服务平台开发(.Net 的实现)3-------发送文本消息

    首先建立一个微信消息类. class wxmessage { public string FromUserName { get; set; } public string ToUserName { g ...

  4. Jquery实现无刷新DropDownList联动

    <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> &l ...

  5. C# DataTable Operations

    DataTable详解 https://www.cnblogs.com/Sandon/p/5175829.html 怎样删除一行 https://www.cnblogs.com/jhxk/articl ...

  6. lintcode---线段树查询||(区间元素个数)

    对于一个数组,我们可以对其建立一棵 线段树, 每个结点存储一个额外的值 count 来代表这个结点所指代的数组区间内的元素个数. (数组中并不一定每个位置上都有元素) 实现一个 query 的方法,该 ...

  7. 学习XML(添加一个子节点) 摘录

    这里介绍添加XML节点的方法. 首先定义XML文件:(bookstore.xml) <?xml version="1.0" encoding="utf-8" ...

  8. [转]html5调用摄像头实例

    原文:https://blog.csdn.net/binquan_liang/article/details/79489989 最近在学习在做HTML5的项目,看了博客上html5调用摄像头拍照的文章 ...

  9. 李洪强iOS开发之Block和协议

    李洪强iOS开发之Block和协议 OC语言BLOCK和协议 一.BOLCK (一)简介 BLOCK是什么?苹果推荐的类型,效率高,在运行中保存代码.用来封装和保存代码,有点像函数,BLOCK可以在任 ...

  10. 03、Windows Phone 套接字(Socket)实战之WP客户端设计

    因为 PC 端和 WP 端进行通信时,采用的自定义的协议,所以也需要定义 DataType 类来判断 通信数据的类型,并且把数据的描述信息(head) 和数据的实际内容(body)进行拼接和反转,所以 ...