Barney lives in NYC. NYC has infinite number of intersections numbered dịch - Barney lives in NYC. NYC has infinite number of intersections numbered Việt làm thế nào để nói

Barney lives in NYC. NYC has infini

Barney lives in NYC. NYC has infinite number of intersections numbered with positive integers starting from 1. There exists a bidirectional road between intersections i and 2i and another road between i and 2i + 1 for every positive integer i. You can clearly see that there exists a unique shortest path between any two intersections.


Initially anyone can pass any road for free. But since SlapsGiving is ahead of us, there will q consecutive events happen soon. There are two types of events:

1. Government makes a new rule. A rule can be denoted by integers v, u and w. As the result of this action, the passing fee of all roads on the shortest path from u to v increases by w dollars.

2. Barney starts moving from some intersection v and goes to intersection u where there's a girl he wants to cuddle (using his fake name Lorenzo Von Matterhorn). He always uses the shortest path (visiting minimum number of intersections or roads) between two intersections.

Government needs your calculations. For each time Barney goes to cuddle a girl, you need to tell the government how much money he should pay (sum of passing fee of all roads he passes).

Input
The first line of input contains a single integer q (1 ≤ q ≤ 1 000).

The next q lines contain the information about the events in chronological order. Each event is described in form 1 v u w if it's an event when government makes a new rule about increasing the passing fee of all roads on the shortest path from u to v by w dollars, or in form 2 v u if it's an event when Barnie goes to cuddle from the intersection v to the intersection u.

1 ≤ v, u ≤ 1018, v ≠ u, 1 ≤ w ≤ 109 states for every description line.

Output
For each event of second type print the sum of passing fee of all roads Barney passes in this event, in one line. Print the answers in chronological order of corresponding events.
0/5000
Từ: -
Sang: -
Kết quả (Việt) 1: [Sao chép]
Sao chép!
Barney lives in NYC. NYC has infinite number of intersections numbered with positive integers starting from 1. There exists a bidirectional road between intersections i and 2i and another road between i and 2i + 1 for every positive integer i. You can clearly see that there exists a unique shortest path between any two intersections.Initially anyone can pass any road for free. But since SlapsGiving is ahead of us, there will q consecutive events happen soon. There are two types of events:1. Government makes a new rule. A rule can be denoted by integers v, u and w. As the result of this action, the passing fee of all roads on the shortest path from u to v increases by w dollars.2. Barney starts moving from some intersection v and goes to intersection u where there's a girl he wants to cuddle (using his fake name Lorenzo Von Matterhorn). He always uses the shortest path (visiting minimum number of intersections or roads) between two intersections.Government needs your calculations. For each time Barney goes to cuddle a girl, you need to tell the government how much money he should pay (sum of passing fee of all roads he passes).InputThe first line of input contains a single integer q (1 ≤ q ≤ 1 000).The next q lines contain the information about the events in chronological order. Each event is described in form 1 v u w if it's an event when government makes a new rule about increasing the passing fee of all roads on the shortest path from u to v by w dollars, or in form 2 v u if it's an event when Barnie goes to cuddle from the intersection v to the intersection u.1 ≤ v, u ≤ 1018, v ≠ u, 1 ≤ w ≤ 109 states for every description line.OutputFor each event of second type print the sum of passing fee of all roads Barney passes in this event, in one line. Print the answers in chronological order of corresponding events.
đang được dịch, vui lòng đợi..
Kết quả (Việt) 2:[Sao chép]
Sao chép!
Barney sống ở New York. NYC có vô số nút giao thông số với số nguyên dương bắt đầu từ 1. Có tồn tại một con đường hai chiều giữa các nút giao thông i và 2i và một con đường khác giữa tôi và 2i + 1 với mọi số nguyên dương i. Bạn có thể thấy rõ rằng có tồn tại một con đường ngắn nhất giữa bất kỳ hai nút giao thông. Ban đầu ai cũng có thể vượt qua bất kỳ đường miễn phí. Nhưng kể từ khi SlapsGiving là phía trước chúng ta, có q sự kiện liên tiếp sẽ xảy ra sớm. Có hai loại sự kiện: 1. Chính phủ tạo ra một quy tắc mới. Một nguyên tắc có thể được biểu hiện bằng số nguyên v, u và w. Theo kết quả của hành động này, phí đi qua tất cả các con đường trên con đường ngắn nhất từ u đến v tăng USD w. 2. Barney bắt đầu chuyển động từ một số ngã tư v và đi đến ngã tư u, nơi có một cô gái mà anh muốn ôm (sử dụng tên giả của ông Lorenzo Von Matterhorn). Ông luôn luôn sử dụng các con đường ngắn nhất (tham số tối thiểu của giao lộ hoặc đường) giữa hai nút giao thông. Chính phủ cần tính toán của bạn. Mỗi lần Barney đi để ôm ấp một cô gái, bạn cần phải nói với chính phủ bao nhiêu tiền anh phải trả (tổng hợp của việc thu phí của tất cả các con đường anh đi). Input Dòng đầu tiên chứa một số nguyên q đơn (1 ≤ q ≤ 1 000). các dòng tiếp theo q chứa các thông tin về các sự kiện trong thứ tự thời gian. Mỗi sự kiện được mô tả trong hình 1 VUW nếu nó là một sự kiện khi chính phủ làm cho một quy định mới về việc tăng lệ phí qua của tất cả các con đường trên con đường ngắn nhất từ u tới v bằng USD w, hoặc ở dạng 2 vu nếu nó là một sự kiện khi Barnie đi để ôm ấp từ ngã tư v đến ngã u. 1 ≤ v, u ≤ 1018, v ≠ u, 1 ≤ w ≤ 109 quốc gia cho tất cả các dòng mô tả. Output với mỗi sự kiện của loại in thứ hai tổng của việc thu phí của tất cả các tuyến đường Barney đi trong sự kiện này, trong một dòng. In các câu trả lời trong thứ tự thời gian của các sự kiện tương ứng.


















đang được dịch, vui lòng đợi..
 
Các ngôn ngữ khác
Hỗ trợ công cụ dịch thuật: Albania, Amharic, Anh, Armenia, Azerbaijan, Ba Lan, Ba Tư, Bantu, Basque, Belarus, Bengal, Bosnia, Bulgaria, Bồ Đào Nha, Catalan, Cebuano, Chichewa, Corsi, Creole (Haiti), Croatia, Do Thái, Estonia, Filipino, Frisia, Gael Scotland, Galicia, George, Gujarat, Hausa, Hawaii, Hindi, Hmong, Hungary, Hy Lạp, Hà Lan, Hà Lan (Nam Phi), Hàn, Iceland, Igbo, Ireland, Java, Kannada, Kazakh, Khmer, Kinyarwanda, Klingon, Kurd, Kyrgyz, Latinh, Latvia, Litva, Luxembourg, Lào, Macedonia, Malagasy, Malayalam, Malta, Maori, Marathi, Myanmar, Mã Lai, Mông Cổ, Na Uy, Nepal, Nga, Nhật, Odia (Oriya), Pashto, Pháp, Phát hiện ngôn ngữ, Phần Lan, Punjab, Quốc tế ngữ, Rumani, Samoa, Serbia, Sesotho, Shona, Sindhi, Sinhala, Slovak, Slovenia, Somali, Sunda, Swahili, Séc, Tajik, Tamil, Tatar, Telugu, Thái, Thổ Nhĩ Kỳ, Thụy Điển, Tiếng Indonesia, Tiếng Ý, Trung, Trung (Phồn thể), Turkmen, Tây Ban Nha, Ukraina, Urdu, Uyghur, Uzbek, Việt, Xứ Wales, Yiddish, Yoruba, Zulu, Đan Mạch, Đức, Ả Rập, dịch ngôn ngữ.

Copyright ©2025 I Love Translation. All reserved.

E-mail: