zoukankan      html  css  js  c++  java
  • 【NOIP2008】【Luogu1149】火柴棒等式

    problem

    solution

    codes

    #include<iostream>
    using namespace std;
    int num(int x){
        int s[11] = {6,2,5,5,4,5,6,3,7,6};
        if(x == 0)return s[0];
        int ans = 0;
        while(x != 0){
            ans += s[x%10];
            x /= 10;
        }
        return ans;
    }
    int main(){
        int n, ans=0;
        cin>>n;
        for(int i = 0; i < 1000; i++)
            for(int j = 0; j < 1000; j++)
                if(num(i)+num(j)+num(i+j)+4 == n)
                    ans++;
        cout<<ans;
        return 0;
    }
    #include<iostream>
    using namespace std;
    int num[11] = {6,2,5,5,4,5,6,3,7,6};
    int main(){
        int n, ans = 0;  cin>>n;
        for(int i = 0; i < 1000; i++){
            for(int j = 0; j < 1000; j++){
                int a = i, b = j, c = i+j, t = 0;
                if(a == 0)t += num[0];
                if(b == 0)t += num[0];
                if(c == 0)t += num[0];
                while(a){
                    t += num[a%10];
                    a /= 10;
                }
                while(b){
                    t += num[b%10];
                    b /= 10;
                }
                while(c){
                    t += num[c%10];
                    c /= 10;
                }
                if(t == n-4) ans++;
            }
        }
        cout<<ans<<"
    ";
        return 0;
    }
  • 相关阅读:
    理财-4
    “大锅”遇险记
    今日份灵感开发
    持续集成简介
    redis clusert分布式集群
    redis 哨兵
    redis 主从复制
    Redis新特性ACL安全策略
    redis 快照持久化RDB和AOF
    redis 基础常用命令
  • 原文地址:https://www.cnblogs.com/gwj1314/p/9444812.html
Copyright © 2011-2022 走看看