感觉模拟题用函数分块写比较清晰~传参的话,字符串要么直接全局,或者指针也是容易操作,总之思路清晰,然后分块清晰,模拟wa的少吧。

这题水题,不说了。

#include <bits/stdc++.h>
using namespace std;
typedef long long LL; int n,m;
int ma[110][5];
void init()
{
for(int i=1;i<=n;i++)
{
for(int j=1;j<=4;j++)
ma[i][j]=-1;
}
} void solve()
{
int num;
num=1;
for(int i=1;i<=n;i++)
{
ma[i][1]=num++;
if(num>m)
return;
ma[i][4]=num++;
if(num>m)
return;
}
for(int i=1;i<=n;i++)
{
ma[i][2]=num++;
if(num>m)
return;
ma[i][3]=num++;
if(num>m)
return;
}
}
void print()
{
// for(int i=1;i<=n;i++)
// {
// for(int j=1;j<=4;j++)
// printf("%d ",ma[i][j]);
// puts("");
// }
int flag=0;
for(int i=1;i<=n;i++)
{
if(ma[i][2]!=-1)
{
if(flag) printf(" ");
flag=1;
printf("%d",ma[i][2]);
}
if(ma[i][1]!=-1)
{
if(flag) printf(" ");
flag=1;
printf("%d",ma[i][1]);
}
if(ma[i][3]!=-1)
{
if(flag) printf(" ");
flag=1;
printf("%d",ma[i][3]);
}
if(ma[i][4]!=-1)
{
if(flag) printf(" ");
flag=1;
printf("%d",ma[i][4]);
}
}
}
int main()
{
scanf("%d%d",&n,&m);
init();
solve();
print();
return 0;
}

CodeForces660B【模拟—水】的更多相关文章

  1. HDOJ 2317. Nasty Hacks 模拟水题

    Nasty Hacks Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Tota ...

  2. POJ 2014:Flow Layout 模拟水题

    Flow Layout Time Limit: 1000MS   Memory Limit: 30000K Total Submissions: 3091   Accepted: 2148 Descr ...

  3. TYVJ P1002 谁拿了最多奖学金 Label:模拟 水

    背景 NOIP2005复赛提高组第一题 描述 某校的惯例是在每学期的期末考试之后发放奖学金.发放的奖学金共有五种,获取的条件各自不同:1)     院士奖学金,每人8000元,期末平均成绩高于80分( ...

  4. UVA 10714 Ants 蚂蚁 贪心+模拟 水题

    题意:蚂蚁在木棍上爬,速度1cm/s,给出木棍长度和每只蚂蚁的位置,问蚂蚁全部下木棍的最长时间和最短时间. 模拟一下,发现其实灰常水的贪心... 不能直接求最大和最小的= =.只要求出每只蚂蚁都走长路 ...

  5. hdu 4891 模拟水题

    http://acm.hdu.edu.cn/showproblem.php?pid=4891 给出一个文本,问说有多少种理解方式. 1. $$中间的,(s1+1) * (s2+1) * ...*(sn ...

  6. Codeforces Round #425 (Div. 2) B. Petya and Exam(字符串模拟 水)

    题目链接:http://codeforces.com/contest/832/problem/B B. Petya and Exam time limit per test 2 seconds mem ...

  7. Codeforces Round #385 (Div. 2)A B C 模拟 水 并查集

    A. Hongcow Learns the Cyclic Shift time limit per test 2 seconds memory limit per test 256 megabytes ...

  8. 第十五届北京师范大学程序设计竞赛现场决赛题解&源码(A.思维,C,模拟,水,坑,E,几何,思维,K,字符串处理)

    #include <bits/stdc++.h> using namespace std; int main() { int T,n,a,b; while(cin>>T) { ...

  9. 模拟水题,查看二维数组是否有一列都为1(POJ2864)

    题目链接:http://poj.org/problem?id=2864 题意:参照题目 哈哈哈,这个题discuss有翻译哦.水到我不想交了. #include <cstdio> #inc ...

随机推荐

  1. ASP.Net MVC upload file with record & validation - Step 6

    Uploading file with other model data, validate model & file before uploading by using DataAnnota ...

  2. 2016/07/07 apmserv5.2.6 Apache启动失败,请检查相关配置。MySQL5.1已启动。

    因为要用PHP做一个程序,在本机上配PHP环境,下了个APMServ5.26,安装很简单,不再多说,装好后,启动,提示错误,具体是:“Apache启动失败,请检查相关配置.√MySQL5.1已启动”, ...

  3. 【BZOJ3162】独钓寒江雪 树同构+DP

    [BZOJ3162]独钓寒江雪 题解:先进行树hash,方法是找重心,如果重心有两个,则新建一个虚点将两个重心连起来,新点即为新树的重心.将重心当做根进行hash,hash函数不能太简单,我的方法是: ...

  4. BZOJ2759: 一个动态树好题

    BZOJ2759: 一个动态树好题 Description 有N个未知数x[1..n]和N个等式组成的同余方程组:x[i]=k[i]*x[p[i]]+b[i] mod 10007其中,k[i],b[i ...

  5. Redis穿透问题解决方案

    缓存穿透 缓存穿透是指用户查询数据,在数据库没有,自然在缓存中也不会有.这样就导致用户查询的时候,在缓存中找不到,每次都要去数据库再查询一遍,然后返回空.这样请求就绕过缓存直接查数据库,这也是经常提的 ...

  6. MYSQL进阶学习笔记十六:MySQL 监控!(视频序号:进阶_35)

    知识点十七:MySQL监控(35) 一.为什么使用MySQL监控 随着软件后期的不断升级,myssql的服务器数量越来越多,软硬件故障的发生概率也越来越高.这个时候就需要一套监控系统,当主机发生异常时 ...

  7. TestNG测试用例编写和执行

    编写TestNG用例测试基本上包括以下步骤: 编写业务逻辑 针对业务逻辑中涉及的方法编写测试类,在代码中插入TestNG的注解 直接执行测试类或者添加一个testng.xml文件 运行 TestNG. ...

  8. 脚踏实地学C#5-扩展方法

    扩展方法(Extension Method) MSDN定义:能够向现有类型“添加”方法,而无需创建新的派生类型.重新编译或以其他方式修改原始类型. 扩展方法须知: 1.扩展方法声明所在的类必须被声明为 ...

  9. HDU3440 House Man (差分约束)

    In Fuzhou, there is a crazy super man. He can’t fly, but he could jump from housetop to housetop. To ...

  10. [TJOI2016 & HEOI2016] 字符串

    [题目链接] https://www.lydsy.com/JudgeOnline/problem.php?id=4556 [算法] 不难发现 , 对于每个询问        ans = max{ mi ...