{"problem":{"name":"Sum of gcd of Tuples (Hard)","description":{"content":"Consider sequences ${A_1,...,A_N}$ of length $N$ consisting of integers between $1$ and $K$ (inclusive). There are $K^N$ such sequences. Find the sum of $\\gcd(A_1, ..., A_N)$ over all of them. Since t","description_type":"Markdown"},"platform":"AtCoder","limit":{"time_limit":2000,"memory_limit":262144},"difficulty":"None","is_remote":true,"is_sync":true,"sync_url":null,"sign":"abc162_e"},"statements":[{"statement_type":"Markdown","content":"Consider sequences ${A_1,...,A_N}$ of length $N$ consisting of integers between $1$ and $K$ (inclusive).\nThere are $K^N$ such sequences. Find the sum of $\\gcd(A_1, ..., A_N)$ over all of them.\nSince this sum can be enormous, print the value modulo $(10^9+7)$.\nHere $\\gcd(A_1, ..., A_N)$ denotes the greatest common divisor of $A_1, ..., A_N$.\n\n## Constraints\n\n*   $2 \\leq N \\leq 10^5$\n*   $1 \\leq K \\leq 10^5$\n*   All values in input are integers.\n\n## Input\n\nInput is given from Standard Input in the following format:\n\n$N$ $K$\n\n[samples]","is_translate":false,"language":"English"}],"meta":{"iden":"abc162_e","tags":[],"sample_group":[["3 2","9\n\n$\\gcd(1,1,1)+\\gcd(1,1,2)+\\gcd(1,2,1)+\\gcd(1,2,2)$ $+\\gcd(2,1,1)+\\gcd(2,1,2)+\\gcd(2,2,1)+\\gcd(2,2,2)$ $=1+1+1+1+1+1+1+2=9$\nThus, the answer is $9$."],["3 200","10813692"],["100000 100000","742202979\n\nBe sure to print the sum modulo $(10^9+7)$."]],"created_at":"2026-03-03 11:01:13"}}