POJ1166The Clocks

luogu上理解下(就是输入改一下)
直接枚举每一种情况。
然后

Run ID  User    Problem Result  Memory  Time    Language    Code Length Submit Time
16993437    huhaoo  1166    Accepted    640K    47MS    G++ 2296B   2017-05-13 11:44:39
/*************************************************************************
    > file name: a.cpp
    > author: huhao
    > mail: 826538400@qq.com 
    > created time: 2017/5/13 9:20:05
 ************************************************************************/
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
#include<string>
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<queue>
using namespace std;
#define inf 0x3f3f3f3f
#define eps 1e-8
#define rt return
#define gc getchar()
#define ll long long
#define fr(i,a,b) for(int i=a,_end_=b;i<=_end_;i++)
#define fd(i,a,b) for(int i=a,_end_=b;i>=_end_;i--)
void swap(int a,int b)
{
    a^=b^=a^=b;
}
int read()
{
    int r=1,t=0;
    char c=gc;
    while(c<'0'||c>'9')
    {
        if(c=='-')
            r=-1;
        else
            r=1;
        c=gc;
    }
    while(c>='0'&&c<='9')
    {
        t=(t<<1)+(t<<3)+(c^48);
        c=gc;
    }
    rt r*t;
}
char readchar(int x,int y)
{
    char c=gc;
    while(c<x||c>y)
        c=gc;
    rt c;
}
int pow(int x,int y)
{
    int k=1;
    while(y)
    {
        if(y&1)
            k*=x;
        x*=x;
        y>>=1;
    }
    rt k;
}
double log(double x,double y)
{
    rt log10(x)/log10(y);
}
int gcd(int x,int y)
{
    rt y?gcd(y,x%y):x;
}
int lcm(int x,int y)
{
    rt x*y/gcd(x,y);
}
int x[10],k[10],p[10];
int main()
{
#ifndef online_judge
    freopen("", "r", stdin);
    freopen("", "w", stdout);
#endif
    fr(i,1,3)
        fr(j,1,3)
            k[i*3+j-3]=x[i*3+j-3]=readchar('0','3')-48;
    fr(_1,0,3)
    fr(_2,0,3)
    fr(_3,0,3)
    fr(_4,0,3)
    fr(_5,0,3)
    fr(_6,0,3)
    fr(_7,0,3)
    fr(_8,0,3)
    fr(_9,0,3)
    {
        x[1]+=_1,x[2]+=_1,x[4]+=_1,x[5]+=_1;
        x[1]+=_2,x[2]+=_2,x[3]+=_2;
        x[2]+=_3,x[3]+=_3,x[5]+=_3,x[6]+=_3;
        x[1]+=_4,x[4]+=_4,x[7]+=_4;
        x[2]+=_5,x[4]+=_5,x[5]+=_5,x[6]+=_5,x[8]+=_5;
        x[3]+=_6,x[6]+=_6,x[9]+=_6;
        x[4]+=_7,x[5]+=_7,x[7]+=_7,x[8]+=_7;
        x[7]+=_8,x[8]+=_8,x[9]+=_8;
        x[5]+=_9,x[6]+=_9,x[8]+=_9,x[9]+=_9;
        bool flag=1;
        fr(i,1,9)
            if(x[i]%4)
            {
                flag=0;
                break;
            }
        if(flag)
        {
            int o=0;
            if(_1)fr(i,1,_1)p[++o]=1;
            if(_2)fr(i,1,_2)p[++o]=2;
            if(_3)fr(i,1,_3)p[++o]=3;
            if(_4)fr(i,1,_4)p[++o]=4;
            if(_5)fr(i,1,_5)p[++o]=5;
            if(_6)fr(i,1,_6)p[++o]=6;
            if(_7)fr(i,1,_7)p[++o]=7;
            if(_8)fr(i,1,_8)p[++o]=8;
            if(_9)fr(i,1,_9)p[++o]=9;
            fr(i,1,o)
                printf("%d%c",p[i],i==o?'\n':' ');
            rt 0;
        }
        fr(i,1,9)
            x[i]=k[i];
    }
    rt 0;
}
  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值