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. c++初始化函数列表

    以下三种情况下需要使用初始化成员列表: 一,需要初始化的数据成员是对象的情况: 二,需要初始化const修饰的类成员: 三,需要初始化引用成员数据: 原因: C++可以定义引用类型的成员变量,引用类型 ...

  2. Linux下的编译器(转)

    转自:http://ju.outofmemory.cn/entry/2051 简单的说,编译器就是一个可执行程序,它专门用于将程序员易于编写的高级语言 (如 C 语言) 翻译为机器可以识别的低级语言. ...

  3. poj 2388 insert sorting

    /** \brief poj 2388 insert sorting 2015 6 12 * * \param * \param * \return * */ #include <iostrea ...

  4. 〖Linux〗Debian 7.1.0 Wheezy使用ltib报错的解决办法

    报错内容: scue@Link:/home/work/ltib$ ./ltib Processing platform: Phytec board with the NXP LPC32XX SoC = ...

  5. PHP LDAP class for Active Directory

    A class for PHP to talk to Active Directory through LDAP.http://sourceforge.net/projects/adldap/

  6. VC、OpenGL、ArcGIS Engine开发的二维三维结合的GIS系统

    一.前言 众所周知,二维GIS技术发展了近四十年,伴随着计算机软硬件以及关系型数据库的飞速发展,二维GIS技术已日臻完善.在对地理信息的分析功能上有着无可比拟的优势.一些宏观的地理信息,一维的地理信息 ...

  7. 项目启动时 Exception in thread "HouseKeeper" java.lang.NullPointerException

    首先查看是否是端口冲突引起,在日志信息该错误位置往上找,如果再无错误信息,而只有该错误,则原因可能如下: 原因: This is because Proxool is not being shutdo ...

  8. (二)hibernate进阶

    1.hibernate.cfg.xml常用配置以上节代码为例 <session-factory> <property name="connection.username&q ...

  9. 每秒处理3百万请求的Web集群搭建-为最佳性能调优 Nginx

    这篇文章是<打造3百万次请求/秒的高性能服务器集群>系列的第2部分,在这个部分中你可以使用任何一种 WEB 服务器,不过我决定使用 Nginx,因其轻量级.高可靠及高性能的优点. 通常来说 ...

  10. Android中的Layout_weight终极研究

    以前在做UI布局时,也经常用Layout_weight属性,有时会遇到莫名其妙的布局问题,但总没研究懂.一直想做深入分析,但总是没耐心.遇到问题就找替代方法解决,但终非长久之计.这次下决心给它弄透! ...