POJ 1218

题目描述看着就乐了,死板得只按着题意来写了ps: tequi是escape的方言版..
#include <iostream>
using namespace std;
int main()
{
    int line,i,k;
    int ln[250];
    //This is the number of lines that follow.
    cin>>line;
    //input
    for(int j=0;j<line;j++){
        cin>>ln[j];//用空格分开
    }
    //output
    for(int m=0;m<line;m++){
        //false 是开着0,true是关着1;
        bool a[100]={}; //n个cell,就会有n-1=4轮,因为是从1开始,不是从0开始.
        for(i=1;i<ln[m];i++)
        {
            for(k=1;k<ln[m];k++){
                if(i%(k+1)==k)
                    a[i]=!a[i];
            }
        }
        int tequi=0;
        for(i=0;i<ln[m];i++){
            if(a[i]==false)
                tequi++;
        }
        cout<<tequi<<endl;
    }

    return 0;
}
时间: 2024-10-11 16:47:04

POJ 1218的相关文章

[ACM] POJ 1218 THE DRUNK JAILER (关灯问题)

THE DRUNK JAILER Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 23246   Accepted: 14641 Description A certain prison contains a long hall of n cells, each right next to each other. Each cell has a prisoner in it, and each cell is locked

HDU 1337 &amp;&amp; POJ 1218&amp;&amp; zju 1350 方法总结

题目链接http://acm.hdu.edu.cn/showproblem.php?pid=1337 杭电 http://poj.org/problem?id=1218清华 http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=1350浙江 原本以为小小的一道水题不值得去总结,但是发现却有好多方法,好神奇啊 方法一:数据挺小的模拟就好 #include<iostream> #include<algorithm> #

开灯问题 —— POJ 1218 THE DRUNK JAILER

对应POJ 题目:点击打开链接 THE DRUNK JAILER Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 24831   Accepted: 15569 Description A certain prison contains a long hall of n cells, each right next to each other. Each cell has a prisoner in it, and eac

POJ 1218 THE DRUNK JAILER

开关问题,有n个灯,分别由n个开关控制,拨一下开关则可以改变灯的状态(开->关 关->开).初始状态灯都是关着的,先把每个开关都拨一下,然后拨一下2的倍数的开关,接着3的倍数,直到n的倍数,问最后有多少灯是开着的. #include <iostream> #include <cstring> using namespace std; int main() { int n; cin>>n; while(n--) { int t, a[110], k; mems

poj 1218 THE DRUNK JAILER【水题】

THE DRUNK JAILER Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 25124   Accepted: 15767 Description A certain prison contains a long hall of n cells, each right next to each other. Each cell has a prisoner in it, and each cell is locked

Pku1218

<span style="background-color: rgb(204, 204, 204);">/* A - THE DRUNK JAILER Time Limit:1000MS Memory Limit:10000KB 64bit IO Format:%I64d & %I64u Submit Status Practice POJ 1218 Description A certain prison contains a long hall of n cel

POJ 3398 / UVA 1218 Perfect Service 树形DP

树形DP Perfect Service Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 1378   Accepted: 668 Description A network is composed of N computers connected by N ? 1 communication links such that any two computers can be communicated via a uniqu

POJ 3449 Geometric Shapes --计算几何,线段相交

题意: 给一些多边形或线段,输出与每一个多边形或线段的有哪一些多边形或线段. 解法: 想法不难,直接暴力将所有的图形处理成线段,然后暴力枚举,相交就加入其vector就行了.主要是代码有点麻烦,一步一步来吧. 还有收集了一个线段旋转的函数. Vector Rotate(Point P,Vector A,double rad){ //以P为基准点把向量A旋转rad return Vector(P.x+A.x*cos(rad)-A.y*sin(rad),P.y+A.x*sin(rad)+A.y*co

POJ题目推荐(转载)

POJ推荐50题1.标记“难”和“稍难”的题目可以看看,思考一下,不做要求,当然有能力的同学可以直接切掉.2.标记为A and B的题目是比较相似的题目,建议大家两个一起做,可以对比总结,且二者算作一个题目.3.列表中大约有70个题目.大家选做其中的50道,且每类题目有最低数量限制.4.这里不少题目在BUPT ACM FTP上面都有代码,请大家合理利用资源.5.50个题目要求每个题目都要写总结,养成良好的习惯.6.这个列表的目的在于让大家对各个方面的算法有个了解,也许要求有些苛刻,教条,请大家谅