l l
    • Create new note
    • Create a note from template
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Write
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
    • Invite by email
      Invitee

      This note has no invitees

    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Note Insights New
    • Engagement control
    • Make a copy
    • Transfer ownership
    • Delete this note
    • Save as template
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Note Insights Versions and GitHub Sync Sharing URL Create Help
Create Create new note Create a note from template
Menu
Options
Engagement control Make a copy Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Write
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
  • Invite by email
    Invitee

    This note has no invitees

  • Publish Note

    Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

    Your note will be visible on your profile and discoverable by anyone.
    Your note is now live.
    This note is visible on your profile and discoverable online.
    Everyone on the web can find and read all notes of this public team.
    See published notes
    Unpublish note
    Please check the box to agree to the Community Guidelines.
    View profile
    Engagement control
    Commenting
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    • Everyone
    Suggest edit
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    Emoji Reply
    Enable
    Import from Dropbox Google Drive Gist Clipboard
       Owned this note    Owned this note      
    Published Linked with GitHub
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    # Dain's CPE練習 ## 100 - The 3n + 1 problem ```c= #include <bits/stdc++.h> using namespace std; int main(){ int i, j; while(cin>>i>>j){ int next,ans=0,temp; cout<<i<<" "<<j<<" "; if(j<i){ temp=i; i=j; j=temp; } for(int t=i;t<=j;t++){ int k=t; next=1; while(k>1){ if(k%2==0){ k=k/2; next++; } else{ k=3*k+1; next++; } } if(next>ans){ ans=next; } } cout<<ans<<endl; } return 0; } ``` #### input ```text= 1 10 10 1 100 200 201 210 900 1000 1 99999 99999 99999 13 36 23 88 ``` #### output ```text= 1 10 20 10 1 20 100 200 125 201 210 89 900 1000 174 1 99999 351 99999 99999 227 13 36 112 23 88 116 ``` ## 10035 - Primary Arithmetic ```C= #include <iostream> using namespace std; int main() { long int a,b; while(cin>>a>>b) { if(a==0 && b==0) { break; } int c=0,counter=0; while(a!=0 || b!=0) { if(a%10+b%10+c>=10) { counter++; c=1; } else { c=0; } a=a/10; b=b/10; } if(counter==0) { cout<<"No carry operation."<<endl; } else if(counter==1) { cout<<"1 carry operation."<<endl; } else { cout<<counter<<" carry operations."<<endl; } } return 0; } ``` ## 10222 - Decode the Mad man ```C= #include <bits/stdc++.h> using namespace std; int main() { string s1=" `1234567890-=qwertyuiop[]asdfghjkl;'zxcvbnm,./"; //建立比對用的字串,先按空白鍵,之後從鍵盤左邊按到右邊就對了。 string s2; while(getline(cin,s2)){//輸入 for(int i=0;i<s2.length();i++){//開始一個一個比對 if(s2[i]>='A'&&s2[i]<='Z')//先大寫換成小寫 s2[i]=s2[i]+32; for(int t=0;t<s1.length();t++){//逐一比對s1 if(s2[i]==s1[0]){//空白鍵不用轉換 cout<<" "; break; } else if(s2[i]==s1[t]){//輸出左邊兩個鍵盤的字 cout<<s1[t-2]; break; } } } cout<<endl;//換行 } return 0; } ``` #### input ``` k[r dyt i[o p '[nt ]y[jyd. ``` #### output ``` how are you i love program ``` ## UVa10019:Funny Encryption Method ```c= #include <bits/stdc++.h> using namespace std; int main() { int n,in1,cn1; cin>>n;//輸入測資數量 while(n--) { int b1=0,b2=0; cin>>in1;//輸入測資 cn1=in1; while(cn1>0)//十進制轉二進制 { if(cn1%2==1)//利用短除法 b1=b1+1;//計算有幾個1 cn1=cn1/2; } cn1=in1; //cn1變回原本的輸入 while(cn1>0)//十六進制轉二進制 { //利用1個位數轉4個位數的方法 int temp=cn1%10;//先取最左邊的位數 while(temp>0)//再利用10進位轉2進位的方法 { if(temp%2==1) b2++; temp=temp/2; } cn1=cn1/10; } cout<<b1<<" "<<b2<<endl;//輸出 } return 0; } ``` #### input ``` 3 265 111 1234 ``` #### output ``` 3 5 6 3 5 5 ``` ## UVa10038:Jolly Jumpers ```c= #include <bits/stdc++.h> using namespace std; int main() { int n,i;//n輸入用 i方便用 while(cin>>n) { int num[n]={0},count[n]={0};//建立輸入用陣列 ,記錄用字串 int jolly=1;//最後判斷是不是jolly for(i=0;i<n;i++)//輸入兼運算 { cin>>num[i];//輸入數列 if(i>0)//i要大於0才可以運算 { int temp=abs(num[i]-num[i-1]);//計算兩兩相鄰的數的差的絕對值 if(temp<n)//temp必須要小於n不然就不是jolly { count[temp]++;//計算這個差出現幾次 if(count[temp]>1||temp==0)//這個差為0或者出現超過一次就不是jolly jolly=0; } else jolly=0; } } if(jolly==1)//輸出 cout<<"Jolly"<<endl; else cout<<"Not jolly"<<endl; } } ``` #### input ``` 4 1 4 2 3 5 1 4 2 -1 6 ``` #### output ``` Jolly Not jolly ``` ## UVA10041 - Vito's Family ```c= #include <bits/stdc++.h> using namespace std; int main(){ int testcase; //測資數量 cin>>testcase; int d[500]={0}; for(int i=0;i<testcase;i++){ int r; //親戚數量 cin>>r; int s[500]; //每個親戚的門牌號碼,上限500人 int best(0); for(int j=0;j<r;j++) cin>>s[j]; sort(s,s+r); best=s[(int)r/2]; //取中位數 for(int j=0;j<r;j++) d[i]+=abs(s[j]-best); } for (int i=0;i<testcase;i++) cout<<d[i]<<endl; return 0; } ``` #### input ``` 2 2 2 4 3 2 4 6 ``` #### output ``` 2 4 ``` ## 10055 - Hashmat the Brave Warrior ```c= #include <bits/stdc++.h> using namespace std; int main () { long long in1,in2,num; while(cin>>in1>>in2)//輸入測資 { num=abs(in1-in2);//相減取絕對值 cout<<num<<endl;//輸出 } return 0; } ``` #### input ``` 10 12 10 14 100 200 4294967296 1 1 4294967296 11264 29580 20092 4195 ``` #### output ``` 2 4 100 4294967295 4294967295 18316 15897 ``` ## 10062 - Tell me the frequencies! ```c= #include<bits/stdc++.h> using namespace std; int main(){ string str; int i, j; bool flag = false; while(getline(cin,str)){ int count[128] = {0}; flag = true; for(i = 0; i < str.length(); i++) count[str[i]]++; for(i = 1; i <= str.length(); i++){ // the number of each ASCII for(j = 127; j >= 32; j--){ // counter of ASCII if(count[j] == i) cout<<j<<" "<<i<<endl; } } } return 0; } ``` #### input ``` AAABBC 122333 ``` #### output ``` 67 1 66 2 65 3 49 1 50 2 51 3 ``` ## UVA10071:Back to High School Physics ```c= #include <bits/stdc++.h> using namespace std; int main() { int t, v; while(cin >> t >> v) cout << 2*t*v << endl; return 0; } ``` #### input ``` 0 0 5 12 -100 0 -100 200 94 86 ``` #### output ``` 0 120 0 -40000 16168 ``` ## 10170:The Hotel with Infinite Rooms ```c= #include <bits/stdc++.h> using namespace std; int main() { long long s,d;//數字很大用long long while(cin>>s>>d){//輸入測資 while(d>0){//d一直減s直到d小於等於0這時s就是答案 d=d-s; s++; } cout<<s-1<<endl;//因為d小於0的那次迴圈s仍會加1所以必須減回來 } return 0; } ``` #### input ``` ``` #### output ``` ``` ## 10242 - Fourth Point ```c= #include <bits/stdc++.h> using namespace std; int main() { int i,t; double x[4],y[4],ax,ay; while(cin>>x[0]>>y[0]){//輸入測資 ax=x[0];//全部的點相加 ay=y[0];//全部的點相加 for(i=1;i<4;i++){//輸入測資 cin>>x[i]>>y[i]; ax+=x[i];//全部點相加 ay+=y[i];//全部點相加 } for(i=0;i<4;i++){ for(t=i+1;t<4;t++){ if(x[i]==x[t]&&y[i]==y[t]){//找到一樣的點 cout<<fixed<<setprecision(3); //精確到小數點下三位 cout<<ax-3*x[i]<<" ";//輸出x座標 cout<<ay-3*y[i]<<endl;//輸出y座標 } } } } return 0; } ``` #### input ``` 0.000 0.000 0.000 1.000 0.000 1.000 1.000 1.000 1.000 0.000 3.500 3.500 3.500 3.500 0.000 1.000 1.866 0.000 3.127 3.543 3.127 3.543 1.412 3.145 ``` #### output ``` 1.000 0.000 -2.500 -2.500 0.151 -0.398 ``` ---------------------------------------------------- ## ```c= ``` #### input ``` ``` #### output ``` ``` ---------------------------------------------------- ## ```c= ``` #### input ``` ``` #### output ``` ``` ---------------------------------------------------- ## ```c= ``` #### input ``` ``` #### output ``` ``` ---------------------------------------------------- ## ```c= ``` #### input ``` ``` #### output ``` ``` ---------------------------------------------------- ## ```c= ``` #### input ``` ``` #### output ``` ``` ---------------------------------------------------- ## ```c= ``` #### input ``` ``` #### output ``` ```

    Import from clipboard

    Paste your markdown or webpage here...

    Advanced permission required

    Your current role can only read. Ask the system administrator to acquire write and comment permission.

    This team is disabled

    Sorry, this team is disabled. You can't edit this note.

    This note is locked

    Sorry, only owner can edit this note.

    Reach the limit

    Sorry, you've reached the max length this note can be.
    Please reduce the content or divide it to more notes, thank you!

    Import from Gist

    Import from Snippet

    or

    Export to Snippet

    Are you sure?

    Do you really want to delete this note?
    All users will lose their connection.

    Create a note from template

    Create a note from template

    Oops...
    This template has been removed or transferred.
    Upgrade
    All
    • All
    • Team
    No template.

    Create a template

    Upgrade

    Delete template

    Do you really want to delete this template?
    Turn this template into a regular note and keep its content, versions, and comments.

    This page need refresh

    You have an incompatible client version.
    Refresh to update.
    New version available!
    See releases notes here
    Refresh to enjoy new features.
    Your user state has changed.
    Refresh to load new user state.

    Sign in

    Forgot password

    or

    By clicking below, you agree to our terms of service.

    Sign in via Facebook Sign in via Twitter Sign in via GitHub Sign in via Dropbox Sign in with Wallet
    Wallet ( )
    Connect another wallet

    New to HackMD? Sign up

    Help

    • English
    • 中文
    • Français
    • Deutsch
    • 日本語
    • Español
    • Català
    • Ελληνικά
    • Português
    • italiano
    • Türkçe
    • Русский
    • Nederlands
    • hrvatski jezik
    • język polski
    • Українська
    • हिन्दी
    • svenska
    • Esperanto
    • dansk

    Documents

    Help & Tutorial

    How to use Book mode

    Slide Example

    API Docs

    Edit in VSCode

    Install browser extension

    Contacts

    Feedback

    Discord

    Send us email

    Resources

    Releases

    Pricing

    Blog

    Policy

    Terms

    Privacy

    Cheatsheet

    Syntax Example Reference
    # Header Header 基本排版
    - Unordered List
    • Unordered List
    1. Ordered List
    1. Ordered List
    - [ ] Todo List
    • Todo List
    > Blockquote
    Blockquote
    **Bold font** Bold font
    *Italics font* Italics font
    ~~Strikethrough~~ Strikethrough
    19^th^ 19th
    H~2~O H2O
    ++Inserted text++ Inserted text
    ==Marked text== Marked text
    [link text](https:// "title") Link
    ![image alt](https:// "title") Image
    `Code` Code 在筆記中貼入程式碼
    ```javascript
    var i = 0;
    ```
    var i = 0;
    :smile: :smile: Emoji list
    {%youtube youtube_id %} Externals
    $L^aT_eX$ LaTeX
    :::info
    This is a alert area.
    :::

    This is a alert area.

    Versions and GitHub Sync
    Get Full History Access

    • Edit version name
    • Delete

    revision author avatar     named on  

    More Less

    Note content is identical to the latest version.
    Compare
      Choose a version
      No search result
      Version not found
    Sign in to link this note to GitHub
    Learn more
    This note is not linked with GitHub
     

    Feedback

    Submission failed, please try again

    Thanks for your support.

    On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

    Please give us some advice and help us improve HackMD.

     

    Thanks for your feedback

    Remove version name

    Do you want to remove this version name and description?

    Transfer ownership

    Transfer to
      Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

        Link with GitHub

        Please authorize HackMD on GitHub
        • Please sign in to GitHub and install the HackMD app on your GitHub repo.
        • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
        Learn more  Sign in to GitHub

        Push the note to GitHub Push to GitHub Pull a file from GitHub

          Authorize again
         

        Choose which file to push to

        Select repo
        Refresh Authorize more repos
        Select branch
        Select file
        Select branch
        Choose version(s) to push
        • Save a new version and push
        • Choose from existing versions
        Include title and tags
        Available push count

        Pull from GitHub

         
        File from GitHub
        File from HackMD

        GitHub Link Settings

        File linked

        Linked by
        File path
        Last synced branch
        Available push count

        Danger Zone

        Unlink
        You will no longer receive notification when GitHub file changes after unlink.

        Syncing

        Push failed

        Push successfully