竹園論壇

標題: 10550 - Combination Lock [打印本頁]

作者: jd3    時間: 2014-7-29 16:56
標題: 10550 - Combination Lock
本帖最後由 domen111 於 2014-8-12 11:54 編輯



這題太機車了!!!

題意釐清:
看好那個鎖!
上面有個紅紅的指針對吧!

轉盤順時針轉的時候數字是減少的

解題策略:
先把轉幾圈整的加到答案裡
問題剩下從起點順時針轉到A,逆時針轉到B,順時針轉到C
起點順時針轉到A = ((s-(a-40))%40)*9
其中9是每一格的角度
逆時針到B = ((b+40)-a)%40) * 9


依此類推


AC code :
[C++] 純文本查看 復制代碼
#include<iostream>
#include<cstdio>

using namespace std;

int main()
{
        int s;
        int a,b,c;
        int ans;
        
        while(1){
        
                scanf("%d%d%d%d", &s, &a, &b, &c);
                if(s==0 && a==0 && b==0 && c==0)
                        return 0;
                ans = 1080;
                ans += ((s-(a-40))%40) * 9;
                ans += (((b+40)-a)%40) * 9;
                ans += ((b-(c-40))%40) * 9;
                printf("%d\n",ans);
        }
        
        return 0;
}







歡迎光臨 竹園論壇 (http://forum.tfcis.org/) Powered by Discuz! X3.2