惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

N
News | PayPal Newsroom
Security Archives - TechRepublic
Security Archives - TechRepublic
Hacker News: Ask HN
Hacker News: Ask HN
H
Hacker News: Front Page
Apple Machine Learning Research
Apple Machine Learning Research
TaoSecurity Blog
TaoSecurity Blog
Help Net Security
Help Net Security
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
V
V2EX
Hugging Face - Blog
Hugging Face - Blog
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
人人都是产品经理
人人都是产品经理
博客园 - 三生石上(FineUI控件)
Security Latest
Security Latest
Cloudbric
Cloudbric
WordPress大学
WordPress大学
S
SegmentFault 最新的问题
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
www.infosecurity-magazine.com
www.infosecurity-magazine.com
Know Your Adversary
Know Your Adversary
A
Arctic Wolf
L
LangChain Blog
Application and Cybersecurity Blog
Application and Cybersecurity Blog
The GitHub Blog
The GitHub Blog
P
Proofpoint News Feed
W
WeLiveSecurity
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
M
MIT News - Artificial intelligence
Google DeepMind News
Google DeepMind News
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
The Cloudflare Blog
小众软件
小众软件
NISL@THU
NISL@THU
云风的 BLOG
云风的 BLOG
P
Privacy & Cybersecurity Law Blog
S
Security @ Cisco Blogs
博客园 - 【当耐特】
I
InfoQ
Vercel News
Vercel News
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
P
Proofpoint News Feed
O
OpenAI News
Google DeepMind News
Google DeepMind News
N
News and Events Feed by Topic
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
K
Kaspersky official blog
T
Threat Research - Cisco Blogs
量子位
宝玉的分享
宝玉的分享

博客园 - 空气

没有不可能的事情 迅景如梭,旧游似梦,烟水程何限 [转]一些web开发中常用的、做成cs文件的js代码 数类 MBTI职业性格测试 Which Programming Lanuguage Are You? 如何解释内存中的内容 好久没来了。。。 第七章: 封装 - 空气 - 博客园 C/C++中的内存管理 经典正则表达式 二叉树的显示 第六章: 字符串 测试-通过Word 2007发布Blog 第五章: 数组 第四章: 从 autoboxing 和 unboxing 认识对象 第三章: 语法入门 1. 让自己习惯C++ 0. 序
软件工厂的考试题目程序
空气 · 2006-12-17 · via 博客园 - 空气

#include <iostream>
using namespace std;

int mul1[5];       // 第一个乘数
int mul2;          // 第二个乘数
int result[5];     // 结果
bool used[10];     // 记录每个数字是否用过

/** 对乘数的每一位进行列举 **/
// digit 是位数: 个十百千分别是1234
// carry 是上一位的进位
void fun(int digit, int carry)
{
    
if (digit > 4)
    
{
        
if (carry > 0)
            
return;

        
/* 找到,输出结果 */
        
int i;
        
for (i = 4; i >= 1; i--)
            cout 
<< mul1[i];
        cout 
<< endl;
        cout 
<< "*  " << mul2 << endl;
        cout 
<< "----" << endl;
        
for (i = 4; i >= 1; i--)
            cout 
<< result[i];
        cout 
<< endl << endl;        
    }


    
int num;
    
int temp;
    
/* 枚举这一位所有的数字 */
    
for (int i = 1; i <= 9; i++)
    
{
        
/* 若数字用过则继续寻找 */
        
// 这里可以剪掉很多枝
        if (used[i])
            
continue;
        temp 
= i * mul2 + carry;
        num 
= temp % 10;
        
if (used[num] || num == 0 || i == num)
            
continue;

        
/* 记录 */
        mul1[digit] 
= i;
        result[digit] 
= num;

        
/* 继续 DFS 遍历 */
        used[i] 
= true;
        used[num] 
= true;
        fun(digit
+1, temp/10);
        used[i] 
= false;
        used[num] 
= false;
    }

}


int main()
{
    
for (mul2 = 2; mul2 <= 9; mul2++)
    
{
        used[mul2] 
= true;
        fun(
10);
        used[mul2] 
= false;
    }


    
return 0;
}


http://blog.sina.com.cn/u/4b09e6080100071n