zoukankan      html  css  js  c++  java
  • XidianOJ 1035 数独 && 1053 正数负数 && 1042 另一个简单的游戏

    三道水题。。

    #include <iostream>
    #include <cstdio>
    #include <cstring>
    #include <algorithm>
    using namespace std;
    int n;
    int main(){
        while (scanf("%d",&n) != EOF){
            if (n > 0){
                printf("yes
    ");
            }
            else if (n < 0){
                printf("no
    ");
            }
            else printf("light
    ");
        }
        return 0;
    } 
    #include <iostream>
    #include <cstdio>
    #include <cstring>
    #include <algorithm>
    
    using namespace std;
    
    #define SIZE 9
    
    int table[10][10];
    bool JudgeCube(int x,int y){
        int incx[10] = {0,0,0,0,1,1,1,2,2,2};
        int incy[10] = {0,0,1,2,0,1,2,0,1,2};
        
        int i,j;
        for (i=1;i<=9;i++){
            int appear[10] = {0};
            int nowx = x + incx[i];
            int nowy = y + incy[i];
            if (appear[table[nowx][nowy]]) {
                return true;;
            }
            else appear[table[nowx][nowy]];
        }
        
        return false;
        
    }
    
    int main(){
        int time,T;
        scanf("%d",&T);
        for (time=1;time<=T;time++){
            int i,j;
            int ok = 1;
            
            for (i=1;i<=SIZE;i++){
                for (j=1;j<=SIZE;j++){
                    scanf("%d",&table[i][j]); 
                }
            }
            for (i=1;i<=SIZE;i++){
                int appear[10] = {0};
                for (j=1;j<=SIZE;j++){
                    if (table[i][j] > 9 || table[i][j] < 1) {
                        ok = 0;
                        goto here;
                    }
                    if (appear[table[i][j]]) {
                        ok = 0;
                        goto here;
                    }
                    else appear[table[i][j]] = 1;
                }
            }
            for (i=1;i<=SIZE;i++){
                int appear[10] = {0};
                for (j=1;j<=SIZE;j++){
                    if (appear[table[j][i]]) {
                        ok = 0;
                        goto here;
                    }
                    else appear[table[j][i]] = 1;
                }
            }
            
            if (JudgeCube(1,1) || JudgeCube(1,4) || JudgeCube(1,7) || 
                JudgeCube(4,1) || JudgeCube(4,4) || JudgeCube(4,7) ||
                JudgeCube(7,1) || JudgeCube(7,4) || JudgeCube(7,7))
                ok = 0;
            
            
            here:
            if (ok) {
                printf("yes
    ");
            }
            else printf("no
    ");
        }
        return 0;
        
    }
    #include <cstdio>
    #include <iostream>
    #include <cstring>
    #include <cmath>
    #include <algorithm>
    #include <queue>
    #include <vector>
    using namespace std;
    
    priority_queue<double,vector<double>,greater<double> > q;
    int main(){
        int time,T;
        scanf("%d",&T);
        for (time=1;time<=T;time++){
            int n;
            scanf("%d",&n);
            int i,j;
            while (!q.empty()) {
                q.pop();
            }
            
            for (i=0;i<n;i++){
                double element;
                scanf("%lf",&element);
                q.push(element);
            }
            while (!q.empty()) {
                double min1 = q.top();
                q.pop();
                double min2 = q.top();
                q.pop();
                double res = (min1+min2) / 2;
                if (q.empty()) {
                    res *= 100;
                    res += 0.5;
                    res = floor(res);
                    res /= 100;
                    printf("%.2lf
    ",res);
                    break;
                }
                q.push(res);
            }
                
            
        } 
        return 0;
    }
  • 相关阅读:
    数组排序去重
    js打印页面添加分页
    使用navicate可视化工具连接mysql数据库错误
    php_smarty模板引擎与.NET_VTemplate模板引擎对比
    JoshChen判断是否微信内置浏览器访问【转载】
    JoshChen毕业设计分享之班级网站-ASP.NET
    JoshChen防止前台恶意修改数据
    JoshChen安卓开发学习,从零开始(2)
    JoshChen安卓开发学习,从零开始(1)
    JoshChen模式笔记之php单例模式
  • 原文地址:https://www.cnblogs.com/ToTOrz/p/6079235.html
Copyright © 2011-2022 走看看