Aha code Three

1. 坑爹的奥数

a. xxx+xxx=xxx(x为1~9,每个使用一次), method 1
#include <stdio.h>
int main(void)
{
    int a, b, c, d, e, f, g, h, i, total=0;
    for(a=1; a<=9; a++)
    for(b=1; b<=9; b++)
    for(c=1; c<=9; c++)
    for(d=1; d<=9; d++)
    for(e=1; e<=9; e++)
    for(f=1; f<=9; f++)
    for(g=1; g<=9; g++)
    for(h=1; h<=9; h++)
    for(i=1; i<=9; i++)
    {
        if(a!=b && a!=c && a!=d && a!=e && a!=f && a!=g && a!=h && a!=i
                && b!=c && b!=d && b!=e && b!=f && b!=g && b!=h && b!=i
                        && c!=d && c!=e && c!=f && c!=g && c!=h && c!=i
                            && d!=e && d!=f && d!=g && d!=h && d!=i
                            && e!=f && e!=g && e!=h && e!=i
                                    && f!=g && f!=h && f!=i
                                       && g!=h && g!=i
                                    && h!=i
                && a*100+b*10+c+d*100+e*10+f == g*100+h*10+i)
        {
            total++;
            printf("%d%d%d+%d%d%d = %d%d%d\n", a, b, c, d, e, f, g, h, i);
        }
    }
    printf("total = %d", total/2);
    getchar();
    getchar();
    return 0;
}
/*编译执行
[email protected]:~/Documents/Exec_important/aha/three_chapter$ ./1_enum01
124+659 = 783
125+739 = 864
127+359 = 486
127+368 = 495
128+367 = 495
128+439 = 567
129+357 = 486
129+438 = 567
129+654 = 783
129+735 = 864
134+658 = 792
135+729 = 864
138+429 = 567
138+654 = 792
139+428 = 567
139+725 = 864
142+596 = 738
142+695 = 837
143+586 = 729
145+692 = 837
146+583 = 729
146+592 = 738
152+487 = 639
152+784 = 936
154+629 = 783
154+638 = 792
154+782 = 936
157+329 = 486
157+482 = 639
158+634 = 792
159+327 = 486
159+624 = 783
162+387 = 549
162+783 = 945
163+782 = 945
167+328 = 495
167+382 = 549
168+327 = 495
173+286 = 459
173+295 = 468
175+293 = 468
176+283 = 459
182+367 = 549
182+394 = 576
182+457 = 639
182+493 = 675
182+754 = 936
182+763 = 945
183+276 = 459
183+492 = 675
183+546 = 729
183+762 = 945
184+392 = 576
184+752 = 936
186+273 = 459
186+543 = 729
187+362 = 549
187+452 = 639
192+384 = 576
192+483 = 675
192+546 = 738
192+645 = 837
193+275 = 468
193+482 = 675
194+382 = 576
195+273 = 468
195+642 = 837
196+542 = 738
214+569 = 783
214+659 = 873
215+478 = 693
215+748 = 963
216+378 = 594
216+738 = 954
218+349 = 567
218+376 = 594
218+439 = 657
218+475 = 693
218+736 = 954
218+745 = 963
219+348 = 567
219+438 = 657
219+564 = 783
219+654 = 873
234+657 = 891
235+746 = 981
236+718 = 954
236+745 = 981
237+654 = 891
238+419 = 657
238+716 = 954
239+418 = 657
241+596 = 837
243+576 = 819
243+675 = 918
245+673 = 918
245+718 = 963
245+736 = 981
246+573 = 819
246+591 = 837
246+735 = 981
248+319 = 567
248+715 = 963
249+318 = 567
251+397 = 648
254+619 = 873
254+637 = 891
257+391 = 648
257+634 = 891
259+614 = 873
264+519 = 783
269+514 = 783
271+593 = 864
271+683 = 954
273+186 = 459
273+195 = 468
273+546 = 819
273+591 = 864
273+645 = 918
273+681 = 954
275+193 = 468
275+418 = 693
275+643 = 918
276+183 = 459
276+318 = 594
276+543 = 819
278+316 = 594
278+415 = 693
281+394 = 675
281+673 = 954
283+176 = 459
283+671 = 954
284+391 = 675
286+173 = 459
291+357 = 648
291+384 = 675
291+546 = 837
291+573 = 864
293+175 = 468
293+571 = 864
294+381 = 675
295+173 = 468
296+541 = 837
297+351 = 648
314+658 = 972
316+278 = 594
317+529 = 846
317+628 = 945
318+249 = 567
318+276 = 594
318+627 = 945
318+654 = 972
319+248 = 567
319+527 = 846
324+567 = 891
324+657 = 981
327+159 = 486
327+168 = 495
327+519 = 846
327+564 = 891
327+618 = 945
327+654 = 981
328+167 = 495
328+617 = 945
329+157 = 486
329+517 = 846
341+586 = 927
342+576 = 918
346+572 = 918
346+581 = 927
348+219 = 567
349+218 = 567
351+297 = 648
352+467 = 819
354+618 = 972
354+627 = 981
357+129 = 486
357+291 = 648
357+462 = 819
357+624 = 981
358+614 = 972
359+127 = 486
362+187 = 549
362+457 = 819
364+527 = 891
367+128 = 495
367+182 = 549
367+452 = 819
367+524 = 891
368+127 = 495
372+546 = 918
376+218 = 594
376+542 = 918
378+216 = 594
381+294 = 675
381+546 = 927
382+167 = 549
382+194 = 576
384+192 = 576
384+291 = 675
386+541 = 927
387+162 = 549
391+257 = 648
391+284 = 675
392+184 = 576
394+182 = 576
394+281 = 675
397+251 = 648
415+278 = 693
418+239 = 657
418+275 = 693
419+238 = 657
428+139 = 567
429+138 = 567
438+129 = 567
438+219 = 657
439+128 = 567
439+218 = 657
452+187 = 639
452+367 = 819
457+182 = 639
457+362 = 819
462+357 = 819
467+352 = 819
475+218 = 693
478+215 = 693
482+157 = 639
482+193 = 675
483+192 = 675
487+152 = 639
492+183 = 675
493+182 = 675
514+269 = 783
517+329 = 846
519+264 = 783
519+327 = 846
524+367 = 891
527+319 = 846
527+364 = 891
529+317 = 846
541+296 = 837
541+386 = 927
542+196 = 738
542+376 = 918
543+186 = 729
543+276 = 819
546+183 = 729
546+192 = 738
546+273 = 819
546+291 = 837
546+372 = 918
546+381 = 927
564+219 = 783
564+327 = 891
567+324 = 891
569+214 = 783
571+293 = 864
572+346 = 918
573+246 = 819
573+291 = 864
576+243 = 819
576+342 = 918
581+346 = 927
583+146 = 729
586+143 = 729
586+341 = 927
591+246 = 837
591+273 = 864
592+146 = 738
593+271 = 864
596+142 = 738
596+241 = 837
614+259 = 873
614+358 = 972
617+328 = 945
618+327 = 945
618+354 = 972
619+254 = 873
624+159 = 783
624+357 = 981
627+318 = 945
627+354 = 981
628+317 = 945
629+154 = 783
634+158 = 792
634+257 = 891
637+254 = 891
638+154 = 792
642+195 = 837
643+275 = 918
645+192 = 837
645+273 = 918
654+129 = 783
654+138 = 792
654+219 = 873
654+237 = 891
654+318 = 972
654+327 = 981
657+234 = 891
657+324 = 981
658+134 = 792
658+314 = 972
659+124 = 783
659+214 = 873
671+283 = 954
673+245 = 918
673+281 = 954
675+243 = 918
681+273 = 954
683+271 = 954
692+145 = 837
695+142 = 837
715+248 = 963
716+238 = 954
718+236 = 954
718+245 = 963
725+139 = 864
729+135 = 864
735+129 = 864
735+246 = 981
736+218 = 954
736+245 = 981
738+216 = 954
739+125 = 864
745+218 = 963
745+236 = 981
746+235 = 981
748+215 = 963
752+184 = 936
754+182 = 936
762+183 = 945
763+182 = 945
782+154 = 936
782+163 = 945
783+162 = 945
784+152 = 936
total = 168
*/
b. xxx+xxx=xxx(x为1~9,每个使用一次), method 2#include <stdio.h>
int main(void)
{
    int a[10], i, total=0, book[10], sum;
    for(a[1]=1; a[1]<=9; a[1]++)
     for(a[2]=1; a[2]<=9; a[2]++)
      for(a[3]=1; a[3]<=9; a[3]++)
       for(a[4]=1; a[4]<=9; a[4]++)
        for(a[5]=1; a[5]<=9; a[5]++)
         for(a[6]=1; a[6]<=9; a[6]++)
          for(a[7]=1; a[7]<=9; a[7]++)
           for(a[8]=1; a[8]<=9; a[8]++)
            for(a[9]=1; a[9]<=9; a[9]++)
        {
            for(i=1; i<=9; i++)//初始化book数组
                book[i] = 0;
            for(i=1; i<=9; i++)//如果某个数出现过就标记一下
                book[a[i]] = 1;
            //统计共出现了多少个不同的数
            sum = 0;
            for(i=1; i<=9; i++)
                sum+=book[i];
            //如果正好出现了9个不同的数,并且满足等式条件,则输出
            if(sum==9 && a[1]*100+a[2]*10+a[3]+a[4]*100+a[5]*10+a[6] == a[7]*100+a[8]*10+a[9])
            {
                total++;
                printf("%d%d%d+%d%d%d = %d%d%d\n", a[1], a[2], a[3], a[4], a[5], a[6], a[7],
                    a[8], a[9]);
            }
        }
    printf("total=%d", total/2);
    getchar();
    getchar();
    return 0;
}
/*编译执行
[email protected]:~/Documents/Exec_important/aha/three_chapter$ ./1_enum02
124+659 = 783
125+739 = 864
127+359 = 486
127+368 = 495
128+367 = 495
128+439 = 567
129+357 = 486
129+438 = 567
129+654 = 783
129+735 = 864
134+658 = 792
135+729 = 864
138+429 = 567
138+654 = 792
139+428 = 567
139+725 = 864
142+596 = 738
142+695 = 837
143+586 = 729
145+692 = 837
146+583 = 729
146+592 = 738
152+487 = 639
152+784 = 936
154+629 = 783
154+638 = 792
154+782 = 936
157+329 = 486
157+482 = 639
158+634 = 792
159+327 = 486
159+624 = 783
162+387 = 549
162+783 = 945
163+782 = 945
167+328 = 495
167+382 = 549
168+327 = 495
173+286 = 459
173+295 = 468
175+293 = 468
176+283 = 459
182+367 = 549
182+394 = 576
182+457 = 639
182+493 = 675
182+754 = 936
182+763 = 945
183+276 = 459
183+492 = 675
183+546 = 729
183+762 = 945
184+392 = 576
184+752 = 936
186+273 = 459
186+543 = 729
187+362 = 549
187+452 = 639
192+384 = 576
192+483 = 675
192+546 = 738
192+645 = 837
193+275 = 468
193+482 = 675
194+382 = 576
195+273 = 468
195+642 = 837
196+542 = 738
214+569 = 783
214+659 = 873
215+478 = 693
215+748 = 963
216+378 = 594
216+738 = 954
218+349 = 567
218+376 = 594
218+439 = 657
218+475 = 693
218+736 = 954
218+745 = 963
219+348 = 567
219+438 = 657
219+564 = 783
219+654 = 873
234+657 = 891
235+746 = 981
236+718 = 954
236+745 = 981
237+654 = 891
238+419 = 657
238+716 = 954
239+418 = 657
241+596 = 837
243+576 = 819
243+675 = 918
245+673 = 918
245+718 = 963
245+736 = 981
246+573 = 819
246+591 = 837
246+735 = 981
248+319 = 567
248+715 = 963
249+318 = 567
251+397 = 648
254+619 = 873
254+637 = 891
257+391 = 648
257+634 = 891
259+614 = 873
264+519 = 783
269+514 = 783
271+593 = 864
271+683 = 954
273+186 = 459
273+195 = 468
273+546 = 819
273+591 = 864
273+645 = 918
273+681 = 954
275+193 = 468
275+418 = 693
275+643 = 918
276+183 = 459
276+318 = 594
276+543 = 819
278+316 = 594
278+415 = 693
281+394 = 675
281+673 = 954
283+176 = 459
283+671 = 954
284+391 = 675
286+173 = 459
291+357 = 648
291+384 = 675
291+546 = 837
291+573 = 864
293+175 = 468
293+571 = 864
294+381 = 675
295+173 = 468
296+541 = 837
297+351 = 648
314+658 = 972
316+278 = 594
317+529 = 846
317+628 = 945
318+249 = 567
318+276 = 594
318+627 = 945
318+654 = 972
319+248 = 567
319+527 = 846
324+567 = 891
324+657 = 981
327+159 = 486
327+168 = 495
327+519 = 846
327+564 = 891
327+618 = 945
327+654 = 981
328+167 = 495
328+617 = 945
329+157 = 486
329+517 = 846
341+586 = 927
342+576 = 918
346+572 = 918
346+581 = 927
348+219 = 567
349+218 = 567
351+297 = 648
352+467 = 819
354+618 = 972
354+627 = 981
357+129 = 486
357+291 = 648
357+462 = 819
357+624 = 981
358+614 = 972
359+127 = 486
362+187 = 549
362+457 = 819
364+527 = 891
367+128 = 495
367+182 = 549
367+452 = 819
367+524 = 891
368+127 = 495
372+546 = 918
376+218 = 594
376+542 = 918
378+216 = 594
381+294 = 675
381+546 = 927
382+167 = 549
382+194 = 576
384+192 = 576
384+291 = 675
386+541 = 927
387+162 = 549
391+257 = 648
391+284 = 675
392+184 = 576
394+182 = 576
394+281 = 675
397+251 = 648
415+278 = 693
418+239 = 657
418+275 = 693
419+238 = 657
428+139 = 567
429+138 = 567
438+129 = 567
438+219 = 657
439+128 = 567
439+218 = 657
452+187 = 639
452+367 = 819
457+182 = 639
457+362 = 819
462+357 = 819
467+352 = 819
475+218 = 693
478+215 = 693
482+157 = 639
482+193 = 675
483+192 = 675
487+152 = 639
492+183 = 675
493+182 = 675
514+269 = 783
517+329 = 846
519+264 = 783
519+327 = 846
524+367 = 891
527+319 = 846
527+364 = 891
529+317 = 846
541+296 = 837
541+386 = 927
542+196 = 738
542+376 = 918
543+186 = 729
543+276 = 819
546+183 = 729
546+192 = 738
546+273 = 819
546+291 = 837
546+372 = 918
546+381 = 927
564+219 = 783
564+327 = 891
567+324 = 891
569+214 = 783
571+293 = 864
572+346 = 918
573+246 = 819
573+291 = 864
576+243 = 819
576+342 = 918
581+346 = 927
583+146 = 729
586+143 = 729
586+341 = 927
591+246 = 837
591+273 = 864
592+146 = 738
593+271 = 864
596+142 = 738
596+241 = 837
614+259 = 873
614+358 = 972
617+328 = 945
618+327 = 945
618+354 = 972
619+254 = 873
624+159 = 783
624+357 = 981
627+318 = 945
627+354 = 981
628+317 = 945
629+154 = 783
634+158 = 792
634+257 = 891
637+254 = 891
638+154 = 792
642+195 = 837
643+275 = 918
645+192 = 837
645+273 = 918
654+129 = 783
654+138 = 792
654+219 = 873
654+237 = 891
654+318 = 972
654+327 = 981
657+234 = 891
657+324 = 981
658+134 = 792
658+314 = 972
659+124 = 783
659+214 = 873
671+283 = 954
673+245 = 918
673+281 = 954
675+243 = 918
681+273 = 954
683+271 = 954
692+145 = 837
695+142 = 837
715+248 = 963
716+238 = 954
718+236 = 954
718+245 = 963
725+139 = 864
729+135 = 864
735+129 = 864
735+246 = 981
736+218 = 954
736+245 = 981
738+216 = 954
739+125 = 864
745+218 = 963
745+236 = 981
746+235 = 981
748+215 = 963
752+184 = 936
754+182 = 936
762+183 = 945
763+182 = 945
782+154 = 936
782+163 = 945
783+162 = 945
784+152 = 936
total=168
*/
时间: 2024-12-27 08:39:04

Aha code Three的相关文章

Aha code Two

1. 解密QQ号-队列 a.解密算法#include <stdio.h> int main(void) { int q[102] = {0,6,3,1,7,5,8,9,2,4}, head, tail; int i; //初始化队列 head = 1; tail = 10; //队列中已经有9个元素了,tail指向队尾的后一个位置 while(head < tail)//当队列不为空的时候执行循环 { //打印队首并将队首出队 printf("debug in here 1\n

从微信官方获取微信公众号名片:http://open.weixin.qq.com/qr/code/?username=haihongruanjian

从微信官方获取微信公众号名片:http://open.weixin.qq.com/qr/code/?username=haihongruanjian 个人的号,不知道怎么获取.

微信 {&quot;errcode&quot;:40029,&quot;errmsg&quot;:&quot;invalid code, hints: [ req_id: Cf.y.a0389s108 ]&quot;}

{"errcode":40029,"errmsg":"invalid code, hints: [ req_id: Cf.y.a0389s108 ]"} 问题:微信网页授权后,获取到 openid 了,一刷新又没了 微信网页授权获取到的 code 只能使用一次(5分钟内有效),使用一次后,马上失效. 页面授权跳转成功,根据 code 也换取到 openid 了. 此时刷新页面,并不会再次进行授权,而是直接刷新了一下上一次授权跳转后的链接,带的还是

在linux系统中安装VSCode(Visual Studio Code)

1.从官网下载压缩包(话说下载下来解压就直接可以运行了咧,都不需要make) 访问Visual Studio Code官网 https://code.visualstudio.com/docs?dv=linux64 我是64位的: wget https://az764295.vo.msecnd.net/stable/7ba55c5860b152d999dda59393ca3ebeb1b5c85f/code-stable-code_1.7.2-1479766213_amd64.tar.gz 2.解

set up trace code tool

這以 GNU GLOBAL 6.5.6 為示範 1: install GNU GLOBAL https://www.gnu.org/software/global/download.html sudo ./configure; 若有以下 error,請看更下方的 Q5 說明. configure: checking "location of ncurses.h file"... configure: error: curses library is required but not f

Ubuntu16.04下安装VS Code

在Ubuntu下面安装Visual Studio Code sudo add-apt-repository ppa:ubuntu-desktop/ubuntu-make sudo apt-get update sudo apt-get install ubuntu-make umake web visual-studio-code 终于又看见亲切的大麻花了

CSDN code使用教程之git用法详解

首先需要下载GIT客户端,http://git-scm.com/downloads...   然后再code.csdn.net上面创建一个项目,如果 你的项目已经存在,那么请建立项目的时候不要选择自动生成readme文件.填写项目名称,去掉下面的勾勾,然后点击创建就OK了. 下面的就是配置本地客户端了,确认你在CSDN id,获取的方式是在登录后,进入passport.csdn.net,在"个人帐号"的最下端查看用户名:也就是你的昵称,我的就是Linux_Google 然后在命令行中输

.NET跨平台之mac 下vs code 多层架构编程

合肥程序员群:49313181.    合肥实名程序员群:128131462 (不愿透露姓名和信息者勿加入,申请备注填写姓名+技术+工作年限) Q  Q:408365330     E-Mail:[email protected] 概述: 为了研究跨平台.NET 开发,我打算利用.NET core 编写一个跨平台的cms,这个CMS我也秉着开源的原则放到github上面,为.NET 开源社区做点小小的贡献吧.如果有兴趣的可以联系我一起为.NET开源和跨平台做点小小的贡献吧.EgojitCMS传送

安装GO语言环境之安装Visual Studio Code插件

在安装Visual Studio Code插件的时候,由于谷歌的限制,在下载下列插件的时候会报错: go get -u -v github.com/nsf/gocode go get -u -v github.com/rogpeppe/godef go get -u -v github.com/golang/lint/golint go get -u -v github.com/lukehoban/go-find-references go get -u -v github.com/lukeho