Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

cout << BFS(n) << endl;就WA,求问原因

Posted by dasepli at 2021-02-21 14:55:39 on Problem 1426
#include <iostream>
#include <queue>
using namespace std;

int BFS(int n){
  queue<long long> myQueue;
  myQueue.push(1);
  while(!myQueue.empty()){ 
    long long tmp = myQueue.front();
    if((tmp%n)==0)
      return tmp; // 必须要在这里输出
    myQueue.pop();
    myQueue.push(tmp * 10); //(tmp << 3) + 2*tmp
    myQueue.push(tmp * 10 + 1);
  }
  return 0;
}


int main(){
  int n;
  while((cin >> n)&&n){
    cout << BFS(n) << endl;
  }
  return 0;
}

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator