zoukankan      html  css  js  c++  java
  • 2016年第六届蓝桥杯C/C++程序设计本科B组决赛 ——一步之遥(填空题题)


    一步之遥

    从昏迷中醒来,小明发现自己被关在X星球的废矿车里。矿车停在平直的废弃的轨道上。
    他的面前是两个按钮,分别写着“F”和“B”。

    小明突然记起来,这两个按钮可以控制矿车在轨道上前进和后退。
    按F,会前进97米。按B会后退127米。
    透过昏暗的灯光,小明看到自己前方1米远正好有个监控探头。
    他必须设法使得矿车正好停在摄像头的下方,才有机会争取同伴的援助。
    或许,通过多次操作F和B可以办到。

    矿车上的动力已经不太足,黄色的警示灯在默默闪烁...
    每次进行 F 或 B 操作都会消耗一定的能量。
    小明飞快地计算,至少要多少次操作,才能把矿车准确地停在前方1米远
    的地方。

    请填写为了达成目标,最少需要操作的次数。

    注意,需要提交的是一个整数,不要填写任何无关内容(比如:解释说明
    等)


    思路:看着很像是搜索bfs,还记得一个农场主去抓一头牛的题目吧!BFS来一发!

     1 #include<stdio.h>
     2 #include<iostream>
     3 #include<string.h>
     4 #include<vector>
     5 #include<math.h>
     6 #include<algorithm>
     7 #include<set>
     8 #include<string.h>
     9 #include<string>
    10 #include<map>
    11 #include<queue>
    12 using namespace std;
    13 #define N 100008
    14 #define ll long long
    15 #define ull unsigned long long
    16 #define inf 0x3f3f3f3f
    17 struct node{
    18     int x,step;
    19     node(int x=0,int step=0):x(x),step(step){}
    20 };
    21 
    22 
    23 int main(){
    24     int a,b;
    25     for(int a=1;a<=100;a++){
    26         for(int b=1;b<=1000;b++){
    27             int s=a*97+b*(-127);
    28             if(s<-100)
    29                 continue;
    30             if(s==1){
    31                 printf("%d %d
    ",a,b);
    32                 return 0;
    33             }
    34         }
    35     }
    36 
    37 
    38     return 0;
    39 }
    View Code
  • 相关阅读:
    Maven导入com.google.common.collect jar包
    poj 2192 Zipper
    poj 3278 Catch That Cow
    poj 2488 A Knight's Journey
    poj 3982 序列
    poj 2109 Power of Cryptography
    poj 3258 3273
    java中大数的一些基本运算
    hdu 1715 大菲波数
    最小生成树模板
  • 原文地址:https://www.cnblogs.com/zhazhaacmer/p/9020676.html
Copyright © 2011-2022 走看看