2025年12月26日 星期五

2025年度投資總結Part 1

 2025年要結束了,想到應該要來總結一下投資

從2014年開始買賣股票,都沒很認真研究股票

都是來自母親的訊息,該買哪支股票,買入後賠錢就攤平

等小賺就賣或賠多就賣,最高單一支個股也有賠到65萬多

來來回回的,到2024年底算是小賺

2025年初覺得以前這樣操作真的不行

雖然從2014年開始買賣股票過程中也有買書來看

但就是很少花時間去研究,只是書看過就看過了

在2025年初滑IG短影片看到一位演講說講一句直接ALL IN個股

這位演講名子忘了是誰,後來找了相關的ALL IN投資

後來試著將資金也來單壓一個股,剛好在2024年底買入1張鴻海

就索性2025年開始都把資金都買入鴻海

但是慢慢買,在遇到4月份的股災前就買得差不多

沒什資金能加碼,把帳上還在賠錢全賣加上投資型保單提領部分

能擠的錢都擠光了 ,就無腦全買鴻海之後就抱著

這段時間上YT看財經、一些理財相關等影片

並關注鴻海相關訊息、籌碼等,不斷地蒐集訊息、學習理財

一邊調整往後的投資股票方式,2025年底出清鴻海後

集中資金再重新調整,根據計畫實施投資方式

計畫將一小部分資金放在ETF,剩下資金ALL IN個股

之後看事做事調整操作方向

2018年8月30日 星期四

Java 明明愛排列

題目: 明明愛排列


import java.util.Scanner;
import java.util.Arrays;

public class RadixSort{
    public static Scanner sc = new Scanner(System.in);
 
    public static void main(String args[]){
        while(sc.hasNext()){
            int n = sc.nextInt();
            int[] temp = new int[n];
            for(int i = 0; i < n; i++){
                temp[i] = sc.nextInt();
            }
            Arrays.sort(temp);
   
            int[] num = new int[10];
            int[][] bucket = new int[10][n];
            for(int j = n-1; j >= 0; j--){
                int lsd = temp[j] % 10;
                bucket[lsd][num[lsd]] = temp[j];
                num[lsd]++;
            }
   
            int m = 0;
            for(int k = 0; k < 10; k++){
                if(num[k] != 0){
                    for(int l =0; l < num[k]; l++){
                        temp[m] = bucket[k][l];
                        m++;
                    }
                }
            }
   
            for(int o : temp){
                System.out.print(o + " ");
            }
            System.out.println();
        }
    }
}

2018年7月30日 星期一

Java 明明愛明明

題目: 明明愛明明


import java.util.Scanner;

public class Palindrome{
    public static Scanner sc = new Scanner(System.in);
 
    public static void main(String args[]){
        while(sc.hasNext()){
            String str = sc.nextLine();
            int[] i = new int[26];
            for(char c : str.toCharArray()){
                if(c >= 'a' && c <= 'z'){
                    i[c-97] += 1;
                }
                else if(c >= 'A' && c <= 'Z'){
                    i[c-65] += 1;
                }
            }
            int o = 0;
            for(int j : i){
                if(j % 2 == 1){
                    o += 1;
                }
            }
            if(o > 1) System.out.println("no...");
            else System.out.println("yes !");
        }
    }
}

2018年7月29日 星期日

Java 數數愛明明

題目: 數數愛明明


import java.util.Scanner;

public class CountingTwo{
    public static Scanner sc = new Scanner(System.in);
 
 
    public static void main(String args[]){
        while(sc.hasNext()){
            Long n = sc.nextLong();
            Long f = ((1 + n)*n)/2;
            Long g = (f*(n+2))/3;
            System.out.println(f + " " + g);
        }
    }
}

參考網站

Java 明明愛數數

題目: 明明愛數數


import java.util.Scanner;

public class Counting{
    public static Scanner sc = new Scanner(System.in);
 
    public static void main(String args[]){
        while(sc.hasNext()){
            int n = sc.nextInt();
            int m = sc.nextInt();
            int total = n;
            int i,j=1;
            for(i = n+1; total <= m; i++){
                total += i;
                j++;
            }
            System.out.println( j );
        }
    }
}

Java 乘乘樂

題目: 乘乘樂


import java.util.Scanner;

public class Multi{
    public static Scanner sc = new Scanner(System.in);
 
    public static void main(String args[]){
        sc.nextInt();
        while(sc.hasNext()){
            Integer n = 1;
            for(char i : sc.next().toCharArray()){
                n *= Character.getNumericValue(i);
            }
            System.out.println(n);
        }
    }
}

Java You Cannot Pass?!

題目: You Cannot Pass?!


import java.util.Scanner;

public class PassScore{
    public static Scanner sc = new Scanner(System.in);
    public static int n,i,score;
 
    public static void main(String args[]){
        while(sc.hasNext()){
            n = sc.nextInt();
            score = 0;
   
            for(i = 1; i <= n; i++){
                score += sc.nextInt();
            }
   
            System.out.println((score > (59*n)) ? "no" : "yes" );
        }
    }
}

Java Print it all

題目: Print it all


import java.util.Scanner;

public class PrintAll{ 
    public static Scanner sc = new Scanner(System.in);
    public static int n,i;
 
    public static void main(String args[]){
        while(sc.hasNext()){
            n = sc.nextInt();
   
            for(i = 1; i < n; i++){
                if(i % 7 != 0){
                    System.out.print(i + " ");
                }
            }
            System.out.println();
        }
    }
}

2018年7月27日 星期五

Java 質數又來囉

題目: 質數又來囉

使用這篇文章判斷質數去修改

import java.util.Scanner;
import java.math.BigInteger;

public class Prime {
  
    public static boolean MillerRabin(BigInteger x, int d, int time, BigInteger n){
        BigInteger nDivOne = n.subtract( BigInteger.ONE );
        BigInteger TWO = BigInteger.valueOf(2);
        x = x.modPow(BigInteger.valueOf(d), n);
  
        if( !x.equals( BigInteger.ONE ) && !x.equals( nDivOne ) ){
   
            while( --time > 0 ){
                x = x.modPow(TWO, n);
                if( x.equals( nDivOne ) ){ return true; }
            }
            return false;
        }
        return true;
    }
 
    public static int d,s;
    public static boolean isPrime(int n){  
        d = n - 1;
        s = 0;
        while( d % 2 == 0 ){
            d /= 2;
            s++;
        }
  
        return MillerRabin(BigInteger.valueOf(2), d, s, BigInteger.valueOf(n)) &&
               MillerRabin(BigInteger.valueOf(7), d, s, BigInteger.valueOf(n)) &&
               MillerRabin(BigInteger.valueOf(61), d, s, BigInteger.valueOf(n));
    }

    public static Scanner sc = new Scanner(System.in);
    public static int a,b,total;
 
    public static void main(String[] args){
          
        while(sc.hasNext()){
            a = sc.nextInt();
            b = sc.nextInt();
            total = 0;
    
            do{
                if(a % 2 ==0 && a > 2 || a == 1){
                    a++;
                    continue;
                }
                switch( a ){
                    case 2: case 5: case 7: case 61:
                        total++;
                        a++;
                        break;
                    default:
                        switch( a % 10 ){
                            case 1: case 3: case 5: case 7: case 9:
                                total += isPrime(a) ? 1 : 0;
                                a+=2;
                                break;
                        }
                        break;
                }
            }while( a <= b );
   
            System.out.println(total);
        }
    }
}

Java 排序

題目: 排序


import java.util.Scanner;
import java.util.Arrays;

public class Sort{
    public static Scanner sc = new Scanner(System.in);
    public static int length,i;
    public static int[] a;
 
    public static void main(String args[]){
        while(sc.hasNext()){
            length = sc.nextInt();
   
            a = new int[length];
            for(i = 0; i < length; i++){
                a[i] = sc.nextInt();
            }
            Arrays.sort(a);
            for(i = 0; i < length; i++){
                System.out.print(a[i] + " ");
            }
            System.out.println();
        }
    }
}

Java 麥哲倫的陰謀

題目: 麥哲倫的陰謀


import java.util.Scanner;

public class GuessHat{
    public static Scanner sc = new Scanner(System.in);
    public static long n,m;
 
    public static void main(String args[]){
   
        while(sc.hasNext()){
            n = sc.nextLong();
            m = sc.nextLong();
   
            System.out.println((m != n) ? m+1 : m);
        }
    }
}

Java 提款卡密碼

題目: 提款卡密碼


import java.util.Scanner;
import java.lang.Math;

public class ATMCard{
    public static Scanner sc = new Scanner(System.in);
    public static String str;
    public static int length,a,b,i;
 
    public static void main(String args[]){
        while(sc.hasNext()){
            str = sc.nextLine();
   
            length = str.length();
            a = (int)(str.charAt(0));
            i = 0;
            while(++i < length){
                b = (int)(str.charAt(i));
                System.out.print(Math.abs(a - b));
                a = b;
            }
            System.out.println();
        }
    }
}

2018年7月26日 星期四

Java 完全平方和

題目: 完全平方和


import java.util.Scanner;
import java.lang.Math;

public class Square{
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
  
        while(sc.hasNext()){
            int n = sc.nextInt();
   
            for(int i = 1; i <= n; i++){
                int a = sc.nextInt();
                int b = (int)Math.sqrt(sc.nextInt());
                int calc = 0;
    
                int s = (int)Math.sqrt(a);
                a = (a > 1) ? ((s*s < a) ? s + 1 : s) : 1;
    
                for(; a <= b; a++){
                    calc += (a*a);
                }
                System.out.println("Case " + i + ": " + calc);
            }
   
        }
    }
 
}

Java MOD3

題目: MOD3


import java.util.Scanner;

public class Mod3{
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
  
        while(sc.hasNext()){
            int a = 0,b = 0,c = 0;
   
            for(int i = sc.nextInt(); i-- > 0;){
                switch (sc.nextInt() % 3){
                    case 0:
                        a++;
                        break;
                    case 1:
                        b++;
                        break;
                    case 2:
                        c++;
                        break;
                }
            }
   
            System.out.println(a + " " + b + " " + c);
        }
    }
}

2014年3月20日 星期四

Java 電話客服中心

題目:電話客服中心


import java.util.Scanner;

public class IdAuthentication{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String str;
  
        while( sc.hasNext() ){
            str = sc.nextLine();
            char c[] = str.toCharArray();
   
            int sum = 0;
            for(int i = 0; i < 8; i++ ){
                sum += (c[i]-48)*(8-i);
            }
            sum += (c[8]-48);
   
            int n;
            for(int a = 65; a <= 90; a++){
                if( a == 88 || a == 89 ){
                    n = a - 58;
                }
                else if( a >= 65 && a <= 72 ){
                    n = a - 55;
                }else if( a >= 74 && a <= 78){
                    n = a - 56;
                }else if( a >= 80 && a <= 86){
                    n = a - 57;
                }else{
                    n = (a == 73) ? 34 : (a == 79) ? 35 : 
                        (a == 87) ? 32 : (a == 90) ? 33 : a;
                }
                if( (sum + (n/10) + ((n%10)*9))%10 == 0 ){
                    System.out.print((char)a);
                }
            }
            System.out.println();
        }
    }
}

Java 判斷質數

判斷質數

輸入: 2 < n < 2147483647


import java.util.Scanner;
import java.math.BigInteger;

public class Prime {
  
    public static boolean MillerRabin(BigInteger x, int d, int time, BigInteger n){
        BigInteger nDivOne = n.subtract( BigInteger.ONE );
        BigInteger TWO = BigInteger.valueOf(2);
        x = x.modPow(BigInteger.valueOf(d), n);
  
        // x = a ^ d mod n,若x=1 or x=n-1,直接跳過
        if( !x.equals( BigInteger.ONE ) && !x.equals( nDivOne ) ){
   
            //在S-1的次數內,x = x ^ 2 mod n,若x=n-1 直接跳過
            while( --time > 0 ){
                x = x.modPow(TWO, n);
                if( x.equals( nDivOne ) ){ return true; }
            }
            return false;
        }
        return true;
 }
 
    public static boolean isPrime(int n){  
        // (x ^ s) * d = n - 1
        int d = n - 1;
        int s = 0;
        while( d % 2 == 0 ){
            d /= 2;
            s++;
        }
  
        return MillerRabin(BigInteger.valueOf(2), d, s, BigInteger.valueOf(n)) &&
               MillerRabin(BigInteger.valueOf(7), d, s, BigInteger.valueOf(n)) &&
               MillerRabin(BigInteger.valueOf(61), d, s, BigInteger.valueOf(n));
    }

    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int num;
  
        while( sc.hasNext() ){
            try{
                num = sc.nextInt();
            }catch(java.util.InputMismatchException e){
                break;
            }
    
            switch( num ){
                case 2: case 5: case 7: case 61:
                    System.out.println( "質數" );
                    break;
                default:
                    switch( num % 10 ){
                        case 1: case 3: case 7: case 9:
                            System.out.println( isPrime(num) ? "質數" : "非質數" );
                            break;
                        default:
                            System.out.println( "非質數" );
                        break;
                    }
                    break;
            }
        }
     }
}


寫完之後,發現記憶體用量異常的大,不知道是不是因為使用BigInteger物件的關係,哈

2012年12月12日 星期三

Java Sagit's 計分程式

題目:Sagit's 計分程式


import java.util.Scanner;

public class Sagits{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
  
        while(sc.hasNext()){
            int number = sc.nextInt();
   
            System.out.println(
                (number > 40) ? 100 : 
                (number > 20) ? 100 - (40 - number) :
                (number > 10) ? 80 - (20 - number) * 2 :
                number * 6
            );
        }
    }
}

Java 空間切割

題目:空間切割

公式: N*(N*N+5)/6+1


import java.util.Scanner;
public class A044 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while (sc.hasNext()) {
            int n = sc.nextInt();
            System.out.println(n*(n*n+5)/6+1);
        }
    }
}

Java 平面圓形切割

題目:平面圓形切割

公式: N*N-N+2


import java.util.Scanner;
public class A042 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while (sc.hasNext()) {
            int n = sc.nextInt();
            System.out.println(n*n -n+2);
        }
    }
}

Java 五則運算

題目:五則運算


參考 中序式轉後序式 後序式運算


注意:此程式用Java SE7去寫,如果是用SE6以下去編譯,switch部分會編譯錯誤


import java.util.*;

public class FiveOperations{
    public static int priority(String str){
        switch( str ){
            case "+": case "-": 
                return 1;
            case "*": case"/": case "%": 
                return 2;
            default: 
                return 0;
        }
    }
 
    public static int count(String op, int a, int b){
        switch( op ){
            case "+": return a + b;
            case "-": return a - b;
            case "*": return a * b;
            case "/": return a / b;
            case "%": return a % b;
            default: throw new ArithmeticException(op + " not defined");
        }
    }

    public static String toPostfix(String str){
        StringBuffer sb = new StringBuffer();
        LinkedList<String> stack = new LinkedList<String>();
        for(String sub : str.split(" ") ){
            if("(".indexOf(sub) != -1){
                stack.add(sub);
            }else if("+-*/%".indexOf(sub) != -1){
                while(!stack.isEmpty() && priority(stack.getLast()) >= priority(sub)){
                    sb.append(stack.removeLast() + " ");
                }
                stack.add(sub);
            }else if(")".indexOf(sub) != -1){
                while( "(".indexOf(stack.getLast()) == -1 ){
                    sb.append(stack.removeLast() + " ");
                }
                stack.removeLast();
            }else{
                sb.append(sub + " ");
            }
        }
  
        while(!stack.isEmpty()){ sb.append(stack.removeLast() + " "); }
        return sb.toString();
    }
 
    public static int answer(String str){
        Stack<Integer> stack = new Stack<Integer>();
        for(String sub : toPostfix(str).split(" ")){
            if("+-*/%".indexOf(sub) != -1){
                int b = stack.pop();
                int a = stack.pop();
                stack.push(count(sub, a, b));
            }else{
                stack.push(Integer.parseInt(String.valueOf(sub)));
            }
        }
        return stack.pop();
    }
 
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String str;
  
        while( sc.hasNext() ){
            str = sc.nextLine();
            System.out.println( answer(str) );
        }
    }
}