[NOIP2008] 火柴棒等式

来源:互联网 发布:什么是数据生态圈 编辑:程序博客网 时间:2024/06/11 03:47

题目:https://www.hrbustacm.com/web/problem.php?id=1360

代码:

#include<stdio.h>#include<string.h>#include<iostream>using namespace std;int maps[11]= {6,2,5,5,4,5,6,3,7,6};int rt[11112];int judge(int k){    int ans=0;    if(k==0)        return 6;    while(k)    {        ans=ans+maps[k%10];        k=k/10;    }    return ans;}int main(){    for(int i=0; i<=1000; i++)        rt[i]=judge(i);    int n;    while(~scanf("%d",&n))    {        if(n<13)        {            printf("0\n");            continue ;        }        n=n-4;        int temp=0;        for(int i=0; i<=1000; i++)        {            for(int j=0; j<=1000; j++)            {                if(rt[i]+rt[j]+rt[i+j]==n&&rt[i+j]!=0)                {                    //printf("%d %d %d\n",rt[i],rt[j],rt[i+j]);                    //printf("%d %d %d\n",i,j,i+j);                    temp++;                }            }        }        printf("%d\n",temp);    }}/*24  23 221128 88 65*/


0 0
原创粉丝点击