poj2196---Specialized Four-Digit Numbers

#include <stdio.h>
#include <stdlib.h>

int main()
{
    int i,sum,sumOfH,sumOfd,tmp1,tmp2,tmp3;
    for(i=2992;i<10000;i++)
    {
        sum=0;
        sumOfd=0;
        sumOfH=0;
        tmp1=i;tmp2=i;tmp3=i;
        while(tmp1)
        {
            sumOfd+=(tmp1 % 12);
            tmp1/=12;
        }
        while(tmp2)
        {
            sumOfH += (tmp2 % 16);
            tmp2/=16;
        }
        while(tmp3)
        {
            sum+=(tmp3 % 10);
            tmp3/=10;
        }
        if(sum==sumOfd && sumOfd==sumOfH)
        {
            printf("%d\n",i);
        }
    }
    return 0;
}

wa2次,每注意要比较的是哪几个值相等

时间: 2024-08-29 07:34:20

poj2196---Specialized Four-Digit Numbers的相关文章

grep Demo

最近在学习Linux的几个非常强大的命令awk, sed, grep. 之前对这些命令只是有非常皮毛的了解. 最近稍微深入的对这些命令进行一些学习.sed的主要功能如下: @1: 正则匹配某个字符串. @2: grep具备递归搜索文件/目录功能. #!/bin/bash #File: grepDemo.sh #Author: lxw #Time: 2014-08-21 #Usage: Demonstration for grep. main(){ #The following 2 lines a

[转]http://lua-users.org/wiki/LpegTutorial

Simple Matching LPeg is a powerful notation for matching text data, which is more capable than Lua string patterns and standard regular expressions. However, like any language you need to know the basic words and how to combine them. The best way to

A1024. Palindromic Number (25)

A number that will be the same when it is written forwards or backwards is known as a Palindromic Number. For example, 1234321 is a palindromic number. All single digit numbers are palindromic numbers. Non-palindromic numbers can be paired with palin

PAT1024. Palindromic Number

A number that will be the same when it is written forwards or backwards is known as a Palindromic Number.  For example, 1234321 is a palindromic number.  All single digit numbers are palindromic numbers. Non-palindromic numbers can be paired with pal

uva 11610 Reverse Prime

Problem FReverse Prime Input: Standard Input Output: Standard Output There are a few 7 digit positive numbers whose reverse number is a prime number and less than 10^6.  For example: 1000070, 1000090 and 1000240 are first few reverse prime numbers be

FZU 2215 Simple Polynomial Problem (多项式乘法 栈)

Problem 2215 Simple Polynomial Problem Time Limit: 1000 mSec    Memory Limit : 32768 KB Problem Description You are given an polynomial of x consisting of only addition marks, multiplication marks, brackets, single digit numbers, and of course the le

1019. General Palindromic Number (20)

A number that will be the same when it is written forwards or backwards is known as a Palindromic Number. For example, 1234321 is a palindromic number. All single digit numbers are palindromic numbers. Although palindromic numbers are most often cons

linux基础-认识系统2-基础命令 bc

linux的计算器 指令bc 1+2 3 2*5 10 10/100 0 设置小数点精度后 10/100 .10 详情 man bc后如下 bc(1)                                                                    bc(1) NAME       bc - An arbitrary precision calculator language SYNTAX       bc [ -hlwsqv ] [long-options]

A1019. General Palindromic Number (20)

A number that will be the same when it is written forwards or backwards is known as a Palindromic Number. For example, 1234321 is a palindromic number. All single digit numbers are palindromic numbers. Although palindromic numbers are most often cons

1019. General Palindromic Number

A number that will be the same when it is written forwards or backwards is known as a Palindromic Number. For example, 1234321 is a palindromic number. All single digit numbers are palindromic numbers. Although palindromic numbers are most often cons